@eagleoutice/flowr 2.17.6 → 2.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/abstract-interpretation/absint-inference.d.ts +9 -25
- package/abstract-interpretation/absint-inference.js +7 -21
- package/abstract-interpretation/branch-paths-interpreter.js +1 -5
- package/abstract-interpretation/branch-paths.d.ts +1 -2
- package/abstract-interpretation/data-frame/arguments.d.ts +3 -14
- package/abstract-interpretation/data-frame/arguments.js +2 -10
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -12
- package/abstract-interpretation/data-frame/dataframe-domain.js +6 -20
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -6
- package/abstract-interpretation/data-frame/dataframe-semantics.js +161 -327
- package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -6
- package/abstract-interpretation/data-frame/semantics.d.ts +3 -0
- package/abstract-interpretation/data-frame/semantics.js +20 -42
- package/abstract-interpretation/data-frame/shape-inference.d.ts +5 -15
- package/abstract-interpretation/domains/abstract-domain.d.ts +7 -21
- package/abstract-interpretation/domains/abstract-domain.js +6 -18
- package/abstract-interpretation/domains/interval-domain.d.ts +2 -6
- package/abstract-interpretation/domains/interval-domain.js +3 -10
- package/abstract-interpretation/domains/lattice.d.ts +14 -42
- package/abstract-interpretation/domains/set-range-domain.d.ts +6 -18
- package/abstract-interpretation/domains/set-range-domain.js +4 -12
- package/abstract-interpretation/domains/state-domain.d.ts +9 -27
- package/abstract-interpretation/domains/value-abstract-domain.d.ts +22 -66
- package/abstract-interpretation/domains/value-abstract-domain.js +3 -9
- package/abstract-interpretation/unsupported-functions.d.ts +2 -6
- package/abstract-interpretation/unsupported-functions.js +3 -9
- package/abstract-interpretation/value-semantics.d.ts +1 -2
- package/benchmark/slicer.d.ts +4 -11
- package/benchmark/slicer.js +8 -24
- package/benchmark/stats/count-comments.d.ts +1 -3
- package/benchmark/stats/count-comments.js +1 -3
- package/benchmark/stats/print.d.ts +3 -10
- package/benchmark/stats/print.js +39 -110
- package/benchmark/stats/sigdb-counts.js +1 -5
- package/benchmark/stats/size-of.js +3 -13
- package/benchmark/stats/stats.d.ts +1 -3
- package/benchmark/stopwatch.d.ts +1 -3
- package/benchmark/stopwatch.js +1 -3
- package/benchmark/summarizer/first-phase/input.d.ts +2 -6
- package/benchmark/summarizer/first-phase/input.js +2 -6
- package/benchmark/summarizer/first-phase/process.d.ts +4 -12
- package/benchmark/summarizer/first-phase/process.js +22 -39
- package/benchmark/summarizer/second-phase/graph.d.ts +0 -1
- package/benchmark/summarizer/second-phase/graph.js +9 -33
- package/benchmark/summarizer/second-phase/process.d.ts +4 -12
- package/benchmark/summarizer/second-phase/process.js +78 -221
- package/benchmark/summarizer/summarizer.d.ts +4 -12
- package/cli/benchmark-app.js +1 -5
- package/cli/benchmark-helper-app.js +2 -10
- package/cli/common/options.d.ts +1 -3
- package/cli/common/options.js +1 -3
- package/cli/common/script.d.ts +1 -3
- package/cli/common/script.js +3 -11
- package/cli/common/scripts-info.d.ts +2 -7
- package/cli/common/scripts-info.js +2 -6
- package/cli/flowr-main-options.d.ts +1 -3
- package/cli/flowr-main-options.js +6 -31
- package/cli/flowr.js +5 -8
- package/cli/repl/commands/repl-commands.d.ts +5 -15
- package/cli/repl/commands/repl-commands.js +7 -17
- package/cli/repl/commands/repl-dataflow.js +4 -4
- package/cli/repl/commands/repl-execute.d.ts +1 -4
- package/cli/repl/commands/repl-execute.js +1 -4
- package/cli/repl/commands/repl-main.d.ts +4 -14
- package/cli/repl/commands/repl-main.js +1 -5
- package/cli/repl/commands/repl-query.js +2 -10
- package/cli/repl/commands/repl-signature.js +2 -3
- package/cli/repl/completion.d.ts +11 -3
- package/cli/repl/completion.js +32 -0
- package/cli/repl/core.d.ts +5 -16
- package/cli/repl/core.js +7 -19
- package/cli/repl/execute.js +3 -11
- package/cli/repl/ghost-hint.js +6 -6
- package/cli/repl/parser/slice-query-parser.d.ts +3 -9
- package/cli/repl/parser/slice-query-parser.js +6 -10
- package/cli/repl/print-version.d.ts +2 -6
- package/cli/repl/print-version.js +4 -8
- package/cli/repl/prompt.d.ts +1 -0
- package/cli/repl/prompt.js +1 -0
- package/cli/repl/server/connection.d.ts +2 -6
- package/cli/repl/server/connection.js +8 -35
- package/cli/repl/server/messages/all-messages.d.ts +3 -9
- package/cli/repl/server/messages/all-messages.js +1 -4
- package/cli/repl/server/messages/message-analysis.d.ts +6 -18
- package/cli/repl/server/messages/message-error.d.ts +1 -3
- package/cli/repl/server/messages/message-hello.d.ts +2 -7
- package/cli/repl/server/messages/message-repl.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.d.ts +2 -7
- package/cli/repl/server/net.d.ts +3 -11
- package/cli/repl/server/net.js +1 -3
- package/cli/repl/server/send.d.ts +2 -6
- package/cli/repl/server/send.js +2 -6
- package/cli/repl/server/server.js +1 -6
- package/cli/repl/server/validate.d.ts +3 -9
- package/cli/repl/server/validate.js +3 -9
- package/cli/script-core/summarizer-core.d.ts +1 -3
- package/cli/script-core/summarizer-core.js +1 -3
- package/cli/summarizer-app.js +1 -4
- package/cli/wiki.d.ts +1 -3
- package/cli/wiki.js +3 -15
- package/clones/algorithms/baxter-ast.js +2 -2
- package/clones/clone-ast.js +2 -2
- package/clones/clone-detector.js +2 -2
- package/config.d.ts +5 -15
- package/config.js +17 -59
- package/control-flow/basic-cfg-guided-visitor.d.ts +2 -6
- package/control-flow/basic-cfg-guided-visitor.js +2 -6
- package/control-flow/cfg-dead-code.d.ts +1 -1
- package/control-flow/cfg-dead-code.js +16 -41
- package/control-flow/cfg-properties.d.ts +1 -3
- package/control-flow/cfg-properties.js +1 -3
- package/control-flow/cfg-simplification.d.ts +2 -6
- package/control-flow/cfg-simplification.js +2 -6
- package/control-flow/cfg-to-basic-blocks.d.ts +1 -3
- package/control-flow/cfg-to-basic-blocks.js +2 -9
- package/control-flow/control-flow-graph.d.ts +16 -49
- package/control-flow/control-flow-graph.js +60 -194
- package/control-flow/dfg-cfg-guided-visitor.d.ts +2 -6
- package/control-flow/dfg-cfg-guided-visitor.js +2 -6
- package/control-flow/happens-before.d.ts +1 -3
- package/control-flow/happens-before.js +1 -3
- package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -7
- package/control-flow/semantic-cfg-guided-visitor.js +12 -45
- package/control-flow/simple-visitor.d.ts +1 -5
- package/control-flow/simple-visitor.js +1 -5
- package/control-flow/syntax-cfg-guided-visitor.d.ts +23 -67
- package/control-flow/syntax-cfg-guided-visitor.js +22 -66
- package/control-flow/useless-loop.d.ts +0 -5
- package/control-flow/useless-loop.js +0 -5
- package/core/pipeline-executor.d.ts +1 -4
- package/core/pipeline-executor.js +2 -8
- package/core/print/print.d.ts +4 -14
- package/core/print/slice-diff-ansi.d.ts +1 -3
- package/core/print/slice-diff-ansi.js +2 -7
- package/core/steps/all/core/01-parse-tree-sitter.js +1 -4
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/core/steps/all/static-slicing/00-slice.d.ts +1 -1
- package/core/steps/all/static-slicing/00-slice.js +1 -3
- package/core/steps/all/static-slicing/10-reconstruct.js +1 -3
- package/core/steps/pipeline/create-pipeline.d.ts +1 -3
- package/core/steps/pipeline/create-pipeline.js +2 -8
- package/core/steps/pipeline/default-pipelines.d.ts +48 -323
- package/core/steps/pipeline/default-pipelines.js +9 -47
- package/core/steps/pipeline/invalid-pipeline-error.d.ts +1 -3
- package/core/steps/pipeline/invalid-pipeline-error.js +1 -3
- package/core/steps/pipeline/pipeline.d.ts +1 -6
- package/core/steps/pipeline-step.d.ts +2 -6
- package/data/packed.js +2 -2
- package/dataflow/cluster.d.ts +1 -3
- package/dataflow/cluster.js +1 -3
- package/dataflow/environments/ambient-contract.d.ts +102 -0
- package/dataflow/environments/ambient-contract.js +134 -0
- package/dataflow/environments/ambient-effect.d.ts +72 -8
- package/dataflow/environments/ambient-effect.js +59 -17
- package/dataflow/environments/ambient-state-name.d.ts +5 -1
- package/dataflow/environments/ambient-state-name.js +8 -5
- package/dataflow/environments/append.d.ts +1 -3
- package/dataflow/environments/append.js +2 -7
- package/dataflow/environments/apply-kill.d.ts +2 -3
- package/dataflow/environments/apply-kill.js +24 -49
- package/dataflow/environments/built-in-config.d.ts +1 -2
- package/dataflow/environments/built-in-proc-name.d.ts +2 -6
- package/dataflow/environments/built-in-proc-name.js +2 -6
- package/dataflow/environments/built-in-props.js +1 -4
- package/dataflow/environments/built-in.d.ts +2 -3
- package/dataflow/environments/built-in.js +3 -6
- package/dataflow/environments/clone.js +1 -4
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +4 -4
- package/dataflow/environments/default-builtin-config/define-helpers.d.ts +4 -0
- package/dataflow/environments/default-builtin-config/define-helpers.js +4 -0
- package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/dev-tooling.js +10 -7
- package/dataflow/environments/default-builtin-config/graphics-devices.js +1 -1
- package/dataflow/environments/default-builtin-config/guard-builders.d.ts +7 -0
- package/dataflow/environments/default-builtin-config/guard-builders.js +7 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +2 -2
- package/dataflow/environments/default-builtin-config/guards.js +2 -7
- package/dataflow/environments/default-builtin-config/index.d.ts +2 -2
- package/dataflow/environments/default-builtin-config/package-data-table.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/package-data-table.js +2 -3
- package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/package-utils.js +18 -4
- package/dataflow/environments/default-builtin-config/shared-configs.d.ts +71 -0
- package/dataflow/environments/default-builtin-config/shared-configs.js +19 -4
- package/dataflow/environments/define.js +1 -4
- package/dataflow/environments/diff.d.ts +4 -10
- package/dataflow/environments/diff.js +3 -9
- package/dataflow/environments/environment.d.ts +2 -4
- package/dataflow/environments/environment.js +9 -18
- package/dataflow/environments/frame-memory.d.ts +0 -1
- package/dataflow/environments/frame-memory.js +0 -1
- package/dataflow/environments/overwrite.js +1 -4
- package/dataflow/environments/query-fn-props.d.ts +9 -3
- package/dataflow/environments/query-fn-props.js +37 -63
- package/dataflow/environments/reference-to-maybe.d.ts +3 -6
- package/dataflow/environments/reference-to-maybe.js +1 -3
- package/dataflow/environments/resolve-helper.d.ts +3 -2
- package/dataflow/environments/resolve-helper.js +2 -0
- package/dataflow/environments/scoping.js +2 -8
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -0
- package/dataflow/eval/resolve/alias-tracking.js +52 -80
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -3
- package/dataflow/eval/resolve/resolve-argument.js +8 -13
- package/dataflow/eval/resolve/resolve-get.js +1 -4
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +1 -3
- package/dataflow/eval/resolve/resolve.d.ts +1 -1
- package/dataflow/eval/resolve/resolve.js +15 -16
- package/dataflow/eval/values/general.js +10 -11
- package/dataflow/eval/values/intervals/interval-constants.d.ts +0 -2
- package/dataflow/eval/values/intervals/interval-constants.js +1 -9
- package/dataflow/eval/values/logical/logical-constants.js +1 -4
- package/dataflow/eval/values/scalar/scalar-constants.d.ts +2 -6
- package/dataflow/eval/values/scalar/scalar-constants.js +4 -18
- package/dataflow/eval/values/sets/set-constants.js +1 -4
- package/dataflow/eval/values/vectors/vector-constants.js +1 -5
- package/dataflow/extractor.js +103 -16
- package/dataflow/fn/argument-roles.d.ts +2 -2
- package/dataflow/fn/argument-roles.js +9 -5
- package/dataflow/fn/call-sites.d.ts +57 -0
- package/dataflow/fn/call-sites.js +167 -0
- package/dataflow/fn/class-declaration.js +2 -2
- package/dataflow/fn/dispatch.js +6 -5
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/frame-reflection.d.ts +3 -3
- package/dataflow/fn/function-props.d.ts +1 -1
- package/dataflow/fn/function-props.js +1 -4
- package/dataflow/fn/function-semantics.d.ts +14 -1
- package/dataflow/fn/function-semantics.js +3 -0
- package/dataflow/fn/guards/built-in-guards.d.ts +2 -2
- package/dataflow/fn/guards/built-in-guards.js +5 -11
- package/dataflow/fn/guards/call-contracts.js +1 -1
- package/dataflow/fn/guards/function-guards.d.ts +3 -3
- package/dataflow/fn/guards/function-guards.js +17 -15
- package/dataflow/fn/guards/guard-claims.js +15 -14
- package/dataflow/fn/guards/guard-knowledge.d.ts +1 -1
- package/dataflow/fn/guards/guard-term.js +2 -2
- package/dataflow/fn/guards/stated-guards.js +1 -1
- package/dataflow/fn/guards/stored-location.d.ts +21 -0
- package/dataflow/fn/guards/stored-location.js +21 -0
- package/dataflow/fn/strict-function.d.ts +1 -1
- package/dataflow/fn/strict-function.js +7 -9
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +1 -5
- package/dataflow/graph/dataflowgraph-builder.d.ts +3 -2
- package/dataflow/graph/dataflowgraph-builder.js +22 -29
- package/dataflow/graph/df-helper.js +18 -31
- package/dataflow/graph/edge.d.ts +3 -9
- package/dataflow/graph/edge.js +2 -6
- package/dataflow/graph/graph-helper.d.ts +2 -3
- package/dataflow/graph/graph.d.ts +1 -2
- package/dataflow/graph/graph.js +8 -13
- package/dataflow/graph/match-args.d.ts +1 -1
- package/dataflow/graph/match-args.js +13 -31
- package/dataflow/graph/quads.js +2 -7
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/graph/vertex.js +1 -5
- package/dataflow/hooks.d.ts +1 -1
- package/dataflow/info.d.ts +8 -25
- package/dataflow/info.js +9 -32
- package/dataflow/internal/control-flow.d.ts +1 -2
- package/dataflow/internal/linker.d.ts +2 -3
- package/dataflow/internal/linker.js +38 -39
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +3 -8
- package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +10 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +31 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +54 -63
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +12 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +9 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +17 -40
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +6 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +23 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +10 -34
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +29 -128
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +4 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +7 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +1 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +4 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +0 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +0 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +1 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +5 -23
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +14 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +17 -28
- package/dataflow/internal/process/functions/call/common.d.ts +2 -2
- package/dataflow/internal/process/functions/call/common.js +4 -5
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -2
- package/dataflow/internal/process/functions/call/nse-kind.d.ts +1 -4
- package/dataflow/internal/process/functions/call/nse-kind.js +1 -4
- package/dataflow/internal/process/functions/call/nse.js +1 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -2
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/dataflow/internal/process/functions/process-argument.d.ts +2 -6
- package/dataflow/internal/process/functions/process-argument.js +3 -11
- package/dataflow/internal/process/functions/process-parameter.d.ts +0 -1
- package/dataflow/internal/process/functions/process-parameter.js +0 -1
- package/dataflow/internal/process/process-named-call.d.ts +1 -3
- package/dataflow/internal/process/process-named-call.js +1 -3
- package/dataflow/internal/process/process-value.d.ts +1 -4
- package/dataflow/internal/process/process-value.js +2 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -3
- package/dataflow/origin/dfg-get-origin.js +10 -30
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +0 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +0 -1
- package/dataflow/processor.d.ts +8 -24
- package/dataflow/processor.js +1 -0
- package/documentation/data/dfg/doc-ambient.js +12 -3
- package/documentation/data/dfg/doc-data-dfg-util.d.ts +2 -6
- package/documentation/data/dfg/doc-data-dfg-util.js +2 -6
- package/documentation/data/faq/faqs.js +1 -3
- package/documentation/data/faq/recommended-configs.js +2 -15
- package/documentation/data/faq/wiki-faq-store.d.ts +1 -3
- package/documentation/data/faq/wiki-faq-store.js +4 -13
- package/documentation/data/interface/doc-writing-code.d.ts +1 -3
- package/documentation/data/interface/doc-writing-code.js +4 -12
- package/documentation/data/server/doc-data-server-messages.js +28 -120
- package/documentation/doc-capabilities.js +2 -2
- package/documentation/doc-readme.d.ts +2 -5
- package/documentation/doc-readme.js +4 -18
- package/documentation/doc-util/doc-benchmarks.d.ts +2 -6
- package/documentation/doc-util/doc-benchmarks.js +2 -6
- package/documentation/doc-util/doc-cfg.d.ts +4 -10
- package/documentation/doc-util/doc-cfg.js +7 -21
- package/documentation/doc-util/doc-cli-option.d.ts +4 -10
- package/documentation/doc-util/doc-cli-option.js +3 -9
- package/documentation/doc-util/doc-dfg.d.ts +10 -9
- package/documentation/doc-util/doc-dfg.js +9 -24
- package/documentation/doc-util/doc-escape.js +1 -7
- package/documentation/doc-util/doc-files.d.ts +2 -6
- package/documentation/doc-util/doc-files.js +2 -6
- package/documentation/doc-util/doc-general.d.ts +0 -10
- package/documentation/doc-util/doc-general.js +0 -18
- package/documentation/doc-util/doc-normalized-ast.js +4 -7
- package/documentation/doc-util/doc-playground.d.ts +1 -1
- package/documentation/doc-util/doc-query.d.ts +6 -8
- package/documentation/doc-util/doc-query.js +9 -12
- package/documentation/doc-util/doc-repl.d.ts +1 -3
- package/documentation/doc-util/doc-repl.js +1 -3
- package/documentation/doc-util/doc-search.d.ts +1 -3
- package/documentation/doc-util/doc-search.js +2 -7
- package/documentation/doc-util/doc-server-message.d.ts +4 -12
- package/documentation/doc-util/doc-server-message.js +4 -12
- package/documentation/doc-util/doc-structure.d.ts +5 -7
- package/documentation/doc-util/doc-structure.js +9 -9
- package/documentation/doc-util/doc-types.d.ts +4 -12
- package/documentation/doc-util/doc-types.js +29 -127
- package/documentation/issue-linting-rule.d.ts +2 -5
- package/documentation/issue-linting-rule.js +1 -3
- package/documentation/wiki-absint.js +3 -6
- package/documentation/wiki-analyzer.d.ts +2 -5
- package/documentation/wiki-analyzer.js +22 -61
- package/documentation/wiki-cfg.d.ts +1 -2
- package/documentation/wiki-cfg.js +23 -56
- package/documentation/wiki-core.d.ts +3 -8
- package/documentation/wiki-core.js +32 -59
- package/documentation/wiki-create-linting-rules.d.ts +1 -2
- package/documentation/wiki-create-linting-rules.js +1 -4
- package/documentation/wiki-dataflow-graph.d.ts +2 -5
- package/documentation/wiki-dataflow-graph.js +73 -129
- package/documentation/wiki-engine.d.ts +2 -5
- package/documentation/wiki-engine.js +3 -11
- package/documentation/wiki-faq.d.ts +2 -5
- package/documentation/wiki-faq.js +1 -3
- package/documentation/wiki-helper-objects.d.ts +2 -5
- package/documentation/wiki-helper-objects.js +3 -5
- package/documentation/wiki-interface.d.ts +2 -5
- package/documentation/wiki-interface.js +14 -54
- package/documentation/wiki-linter.d.ts +2 -8
- package/documentation/wiki-linter.js +23 -94
- package/documentation/wiki-linting-and-testing.d.ts +2 -5
- package/documentation/wiki-linting-and-testing.js +4 -9
- package/documentation/wiki-mk/doc-context.d.ts +6 -14
- package/documentation/wiki-mk/doc-context.js +8 -28
- package/documentation/wiki-mk/doc-maker.d.ts +9 -27
- package/documentation/wiki-mk/doc-maker.js +6 -18
- package/documentation/wiki-normalized-ast.d.ts +2 -5
- package/documentation/wiki-normalized-ast.js +2 -7
- package/documentation/wiki-onboarding.d.ts +2 -5
- package/documentation/wiki-onboarding.js +1 -3
- package/documentation/wiki-overview.d.ts +2 -5
- package/documentation/wiki-overview.js +1 -3
- package/documentation/wiki-query.d.ts +2 -5
- package/documentation/wiki-query.js +165 -343
- package/documentation/wiki-search.d.ts +2 -5
- package/documentation/wiki-search.js +1 -3
- package/documentation/wiki-setup.d.ts +2 -5
- package/documentation/wiki-setup.js +1 -3
- package/documentation/wiki-signature-database.d.ts +2 -5
- package/documentation/wiki-signature-database.js +3 -5
- package/engines.d.ts +1 -4
- package/engines.js +1 -4
- package/linter/linter-executor.d.ts +1 -3
- package/linter/linter-executor.js +3 -11
- package/linter/linter-fix.d.ts +5 -0
- package/linter/linter-fix.js +7 -22
- package/linter/linter-format.d.ts +23 -55
- package/linter/linter-format.js +13 -26
- package/linter/linter-rules.d.ts +87 -74
- package/linter/linter-rules.js +20 -8
- package/linter/linter-tags.d.ts +9 -29
- package/linter/linter-tags.js +9 -29
- package/linter/rules/{absolute-path.d.ts → absolute-file-paths.d.ts} +10 -10
- package/linter/rules/{absolute-path.js → absolute-file-paths.js} +16 -20
- package/linter/rules/cmd-check/call-arguments.js +2 -11
- package/linter/rules/cmd-check/class-string-comparison.js +1 -4
- package/linter/rules/cmd-check/cmd-check-util.d.ts +3 -0
- package/linter/rules/cmd-check/cmd-check-util.js +17 -7
- package/linter/rules/cmd-check/compiled-code.js +6 -6
- package/linter/rules/cmd-check/dependency-declaration.js +4 -10
- package/linter/rules/cmd-check/description-metadata.js +5 -9
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +9 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +11 -69
- package/linter/rules/cmd-check/file-checks.d.ts +5 -0
- package/linter/rules/cmd-check/file-checks.js +5 -3
- package/linter/rules/cmd-check/foreign-function-calls.js +5 -7
- package/linter/rules/cmd-check/global-environment-modification.js +6 -9
- package/linter/rules/cmd-check/namespace-tampering.js +14 -24
- package/linter/rules/cmd-check/non-ascii-code.js +1 -4
- package/linter/rules/cmd-check/package-data.js +4 -4
- package/linter/rules/cmd-check/package-files.d.ts +1 -3
- package/linter/rules/cmd-check/package-files.js +2 -2
- package/linter/rules/cmd-check/package-hooks.js +1 -4
- package/linter/rules/cmd-check/package-metafiles.d.ts +2 -2
- package/linter/rules/cmd-check/package-metafiles.js +5 -23
- package/linter/rules/cmd-check/package-runtime.js +6 -19
- package/linter/rules/cmd-check/package-structure.js +7 -8
- package/linter/rules/cmd-check/rd-files.d.ts +2 -2
- package/linter/rules/cmd-check/rd-files.js +31 -37
- package/linter/rules/cmd-check/s-three-method-consistency.js +8 -13
- package/linter/rules/cmd-check/true-false-abbreviation.js +1 -3
- package/linter/rules/dataframe-access-validation.d.ts +9 -9
- package/linter/rules/dataframe-access-validation.js +2 -2
- package/linter/rules/dead-code.js +2 -15
- package/linter/rules/deprecated-functions.d.ts +2 -4
- package/linter/rules/deprecated-functions.js +45 -141
- package/linter/rules/file-path-validity.d.ts +1 -3
- package/linter/rules/file-path-validity.js +20 -61
- package/linter/rules/function-finder-util.d.ts +4 -9
- package/linter/rules/function-finder-util.js +5 -16
- package/linter/rules/interactive-functions.js +1 -3
- package/linter/rules/naming-convention.d.ts +5 -15
- package/linter/rules/naming-convention.js +14 -54
- package/linter/rules/network-functions.d.ts +3 -7
- package/linter/rules/network-functions.js +1 -3
- package/linter/rules/overwritten-file.js +4 -4
- package/linter/rules/problematic-inputs.d.ts +1 -2
- package/linter/rules/problematic-inputs.js +1 -4
- package/linter/rules/process-state-in-session.d.ts +0 -1
- package/linter/rules/process-state-in-session.js +6 -6
- package/linter/rules/roxygen-arguments.d.ts +6 -6
- package/linter/rules/roxygen-arguments.js +2 -2
- package/linter/rules/seeded-randomness.d.ts +2 -4
- package/linter/rules/seeded-randomness.js +9 -9
- package/linter/rules/software-has-license.js +1 -3
- package/linter/rules/software-has-tests.js +2 -10
- package/linter/rules/{stop-with-call-arg.d.ts → stop-call.d.ts} +6 -6
- package/linter/rules/{stop-with-call-arg.js → stop-call.js} +4 -6
- package/linter/rules/syntactically-valid.js +17 -44
- package/linter/rules/unclosed-connection.d.ts +1 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.js +24 -60
- package/linter/rules/unescaped-arguments.d.ts +10 -30
- package/linter/rules/unescaped-arguments.js +20 -53
- package/linter/rules/{unused-definition.d.ts → unused-definitions.d.ts} +12 -14
- package/linter/rules/{unused-definition.js → unused-definitions.js} +41 -84
- package/linter/rules/unused-import.d.ts +1 -1
- package/linter/rules/unused-import.js +4 -13
- package/linter/rules/useless-loop.js +3 -13
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +2 -7
- package/project/cache/flowr-analyzer-cache.js +5 -14
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +2 -3
- package/project/cache/flowr-analyzer-controlflow-cache.js +0 -1
- package/project/cache/flowr-cache.d.ts +2 -7
- package/project/cache/flowr-cache.js +2 -7
- package/project/context/abstract-flowr-analyzer-context.d.ts +7 -22
- package/project/context/abstract-flowr-analyzer-context.js +5 -16
- package/project/context/flowr-analyzer-context.d.ts +7 -12
- package/project/context/flowr-analyzer-context.js +8 -22
- package/project/context/flowr-analyzer-dependencies-context.d.ts +7 -19
- package/project/context/flowr-analyzer-dependencies-context.js +6 -21
- package/project/context/flowr-analyzer-environment-context.d.ts +12 -30
- package/project/context/flowr-analyzer-environment-context.js +4 -15
- package/project/context/flowr-analyzer-files-context.d.ts +14 -37
- package/project/context/flowr-analyzer-files-context.js +27 -87
- package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
- package/project/context/flowr-analyzer-gas-context.js +9 -31
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -10
- package/project/context/flowr-analyzer-incremental-analysis-context.js +2 -6
- package/project/context/flowr-analyzer-loading-order-context.d.ts +5 -15
- package/project/context/flowr-analyzer-meta-context.d.ts +8 -33
- package/project/context/flowr-analyzer-meta-context.js +0 -1
- package/project/context/flowr-file.d.ts +6 -14
- package/project/context/flowr-file.js +1 -3
- package/project/dependency-version-space.d.ts +1 -3
- package/project/dependency-version-space.js +41 -135
- package/project/flowr-analyzer-builder.d.ts +7 -5
- package/project/flowr-analyzer-builder.js +10 -12
- package/project/flowr-analyzer.d.ts +12 -34
- package/project/flowr-analyzer.js +5 -14
- package/project/incremental/incremental-parse/edit-computation.js +1 -8
- package/project/incremental/incremental-parse/incremental-parse.js +3 -12
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +13 -35
- package/project/plugins/file-plugins/files/flowr-description-file.js +12 -38
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -2
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +1 -4
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -2
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +8 -42
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -7
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +1 -2
- package/project/plugins/file-plugins/files/flowr-rd-file.js +17 -32
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +15 -40
- package/project/plugins/file-plugins/files/flowr-rda-file.js +343 -819
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +6 -18
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -34
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +1 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +4 -13
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -18
- package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +2 -6
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +2 -6
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +1 -4
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -4
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +1 -3
- package/project/plugins/flowr-analyzer-plugin.d.ts +2 -6
- package/project/plugins/flowr-analyzer-plugin.js +2 -6
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +1 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +1 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -4
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +13 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +0 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +7 -35
- package/project/plugins/package-version-plugins/package.d.ts +1 -1
- package/project/plugins/plugin-registry.d.ts +3 -10
- package/project/plugins/plugin-registry.js +3 -10
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +1 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -8
- package/project/sigdb/build.d.ts +2 -0
- package/project/sigdb/build.js +119 -185
- package/project/sigdb/decode.d.ts +1 -1
- package/project/sigdb/decode.js +3 -4
- package/project/sigdb/guarded-source.js +2 -2
- package/project/sigdb/manifest.js +10 -10
- package/project/sigdb/memory-source.d.ts +1 -1
- package/project/sigdb/memory-source.js +1 -1
- package/project/sigdb/on-demand/package-sources.js +2 -2
- package/project/sigdb/on-demand/recoverer.d.ts +1 -1
- package/project/sigdb/on-demand/remote-sources.js +2 -2
- package/project/sigdb/reader.d.ts +36 -25
- package/project/sigdb/reader.js +63 -81
- package/project/sigdb/sigdb-download.js +2 -12
- package/project/sigdb/signature-db.d.ts +1 -1
- package/project/sigdb/signature-db.js +6 -6
- package/project/sigdb/spec-query.js +4 -4
- package/queries/base-query-format.js +2 -8
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -3
- package/queries/catalog/absint-query/absint-query-format.js +4 -19
- package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +2 -4
- package/queries/catalog/ambient-access-query/ambient-access-query-format.js +2 -4
- package/queries/catalog/call-context-query/call-context-query-executor.js +7 -45
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -21
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +5 -11
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -10
- package/queries/catalog/call-context-query/identify-link-to-relation.d.ts +1 -4
- package/queries/catalog/call-context-query/identify-link-to-relation.js +1 -4
- package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +1 -3
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -7
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -3
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +3 -7
- package/queries/catalog/cluster-query/cluster-query-format.js +5 -13
- package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +2 -4
- package/queries/catalog/code-clones-query/code-clones-query-format.js +5 -18
- package/queries/catalog/config-query/config-query-format.d.ts +1 -3
- package/queries/catalog/config-query/config-query-format.js +1 -3
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +3 -10
- package/queries/catalog/control-flow-query/control-flow-query-format.js +5 -13
- package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +2 -4
- package/queries/catalog/data-columns-query/data-columns-query-format.js +5 -10
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +2 -6
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +3 -11
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -6
- package/queries/catalog/dataflow-query/dataflow-query-format.js +3 -11
- package/queries/catalog/dependencies-query/data-flow.js +5 -4
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -15
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.js +10 -34
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +0 -1
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +6 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +24 -17
- package/queries/catalog/dependencies-query/function-info/tagged-functions.js +1 -4
- package/queries/catalog/dependencies-query/function-info/test-functions.js +2 -8
- package/queries/catalog/dependencies-query/function-info/transform-functions.js +1 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +1 -3
- package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -3
- package/queries/catalog/dependencies-query/plot-description.js +2 -2
- package/queries/catalog/dice-query/dice-query-format.js +2 -8
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -3
- package/queries/catalog/does-call-query/does-call-query-format.js +8 -35
- package/queries/catalog/files-query/files-query-format.d.ts +3 -7
- package/queries/catalog/files-query/files-query-format.js +8 -46
- package/queries/catalog/function-info-query/function-info-query-executor.js +1 -7
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -4
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -3
- package/queries/catalog/id-map-query/id-map-query-format.js +3 -11
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +1 -3
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -7
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -2
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +5 -11
- package/queries/catalog/input-sources-query/simple-input-classifier.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -7
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +7 -10
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +2 -2
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +4 -6
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +2 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +4 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -3
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -4
- package/queries/catalog/linter-query/linter-query-format.js +4 -26
- package/queries/catalog/location-map-query/location-map-query-format.js +4 -20
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +2 -6
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +3 -11
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -3
- package/queries/catalog/origin-query/origin-query-format.js +3 -14
- package/queries/catalog/project-query/project-query-format.d.ts +3 -5
- package/queries/catalog/project-query/project-query-format.js +2 -7
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +4 -10
- package/queries/catalog/provenance-query/provenance-query-format.js +3 -10
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -7
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +6 -23
- package/queries/catalog/search-query/search-query-format.d.ts +1 -3
- package/queries/catalog/search-query/search-query-format.js +3 -11
- package/queries/catalog/signature-query/signature-query-executor.d.ts +1 -1
- package/queries/catalog/signature-query/signature-query-executor.js +15 -40
- package/queries/catalog/signature-query/signature-query-render.d.ts +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +6 -4
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -4
- package/queries/catalog/taint-query/taint-query-format.d.ts +3 -5
- package/queries/catalog/taint-query/taint-query-format.js +5 -46
- package/queries/query-function-filter.js +7 -33
- package/queries/query-function-property.d.ts +1 -1
- package/queries/query-function-property.js +4 -7
- package/queries/query-meta.d.ts +2 -0
- package/queries/query-meta.js +8 -0
- package/queries/query-print.d.ts +6 -10
- package/queries/query-print.js +20 -75
- package/queries/query.d.ts +20 -32
- package/queries/query.js +46 -70
- package/queries/virtual-query/compound-query.d.ts +2 -7
- package/queries/virtual-query/compound-query.js +2 -8
- package/queries/virtual-query/virtual-queries.js +1 -3
- package/r-bridge/data/get.d.ts +1 -3
- package/r-bridge/data/get.js +1 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +19 -59
- package/r-bridge/lang-4.x/ast/model/model.js +9 -27
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +5 -14
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +2 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +9 -25
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +6 -18
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +4 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +2 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -7
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +5 -15
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +3 -10
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +3 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +2 -7
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +4 -14
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +42 -126
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -6
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +1 -3
- package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +18 -0
- package/r-bridge/lang-4.x/ast/model/processing/role.js +25 -0
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -3
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +2 -2
- package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -5
- package/r-bridge/lang-4.x/ast/model/type.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +5 -17
- package/r-bridge/lang-4.x/ast/parser/json/format.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -7
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +2 -12
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +1 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -6
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -7
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +3 -23
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +1 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-line-directive.js +7 -30
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.d.ts +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.js +2 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +3 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +6 -21
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +7 -19
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +8 -26
- package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.d.ts +4 -12
- package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.js +1 -3
- package/r-bridge/lang-4.x/convert-values.d.ts +6 -20
- package/r-bridge/lang-4.x/convert-values.js +10 -41
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -5
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +39 -208
- package/r-bridge/parser.d.ts +1 -3
- package/r-bridge/parser.js +1 -4
- package/r-bridge/retriever.d.ts +5 -16
- package/r-bridge/retriever.js +5 -17
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-ast.d.ts +5 -15
- package/r-bridge/roxygen2/roxygen-ast.js +2 -6
- package/r-bridge/roxygen2/roxygen-parse.d.ts +2 -1
- package/r-bridge/roxygen2/roxygen-parse.js +4 -13
- package/r-bridge/shell-executor.d.ts +3 -9
- package/r-bridge/shell-executor.js +4 -13
- package/r-bridge/shell.d.ts +7 -24
- package/r-bridge/shell.js +8 -29
- package/reconstruct/auto-select/auto-select-defaults.d.ts +1 -3
- package/reconstruct/auto-select/auto-select-defaults.js +1 -3
- package/reconstruct/reconstruct.js +5 -15
- package/search/flowr-search-builder.d.ts +16 -48
- package/search/flowr-search-builder.js +15 -46
- package/search/flowr-search-executor.d.ts +1 -3
- package/search/flowr-search-executor.js +1 -3
- package/search/flowr-search-filters.d.ts +5 -9
- package/search/flowr-search-filters.js +4 -13
- package/search/flowr-search-printer.d.ts +3 -9
- package/search/flowr-search-printer.js +3 -9
- package/search/flowr-search-traverse.d.ts +1 -3
- package/search/flowr-search-traverse.js +1 -3
- package/search/flowr-search.d.ts +6 -19
- package/search/search-executor/search-enrichers.d.ts +5 -15
- package/search/search-executor/search-enrichers.js +6 -25
- package/search/search-executor/search-generators.d.ts +3 -9
- package/search/search-executor/search-generators.js +4 -10
- package/search/search-executor/search-mappers.d.ts +1 -3
- package/search/search-executor/search-mappers.js +1 -3
- package/search/search-executor/search-transformer.d.ts +3 -9
- package/search/search-executor/search-transformer.js +2 -6
- package/search/search-optimizer/search-optimizer.d.ts +1 -4
- package/search/search-optimizer/search-optimizer.js +4 -26
- package/slicing/criterion/collect-all.d.ts +1 -3
- package/slicing/criterion/filters/all-variables.js +2 -9
- package/slicing/criterion/parse.d.ts +2 -6
- package/slicing/criterion/parse.js +3 -9
- package/slicing/static/fingerprint.d.ts +1 -1
- package/slicing/static/removal-slice.js +2 -2
- package/slicing/static/slice-call.d.ts +2 -4
- package/slicing/static/slice-call.js +2 -4
- package/slicing/static/slicer-types.d.ts +3 -9
- package/slicing/static/static-slicer.d.ts +1 -4
- package/slicing/static/static-slicer.js +7 -11
- package/slicing/static/visiting-queue.d.ts +0 -1
- package/slicing/static/visiting-queue.js +0 -1
- package/taint-analysis/builder/domain.d.ts +1 -2
- package/taint-analysis/builder/domain.js +1 -6
- package/taint-analysis/builder/report-template.d.ts +4 -11
- package/taint-analysis/builder/report-template.js +2 -7
- package/taint-analysis/builder/taint-analysis-definition.d.ts +2 -3
- package/taint-analysis/builder/taint-analysis-definition.js +1 -5
- package/taint-analysis/builder/taint-analysis.d.ts +9 -25
- package/taint-analysis/builder/taint-analysis.js +1 -3
- package/taint-analysis/builtin-index-bridge.js +1 -7
- package/taint-analysis/function-categories.d.ts +4 -7
- package/taint-analysis/function-categories.js +4 -15
- package/taint-analysis/predefined/normalization.js +5 -10
- package/taint-analysis/predefined/predefined.d.ts +0 -1
- package/taint-analysis/predefined/predefined.js +1 -2
- package/taint-analysis/predefined/randomness-analysis.js +4 -16
- package/taint-analysis/predefined/secret-analysis.js +2 -8
- package/taint-analysis/predefined/security-analysis.js +9 -43
- package/taint-analysis/taint-mapping.d.ts +4 -13
- package/taint-analysis/taint-mapping.js +3 -9
- package/taint-analysis/taint-resolve.d.ts +2 -3
- package/taint-analysis/taint-visitor.d.ts +1 -3
- package/taint-analysis/taint-visitor.js +2 -2
- package/util/arg-matching.js +4 -4
- package/util/assert.d.ts +1 -3
- package/util/assert.js +2 -5
- package/util/collections/arrays.d.ts +9 -30
- package/util/collections/arrays.js +5 -18
- package/util/collections/defaultmap.d.ts +2 -7
- package/util/collections/defaultmap.js +2 -7
- package/util/collections/objectmap.d.ts +2 -6
- package/util/collections/objectmap.js +2 -6
- package/util/collections/set.d.ts +2 -6
- package/util/collections/set.js +2 -6
- package/util/diff-graph.d.ts +1 -3
- package/util/diff-graph.js +2 -8
- package/util/diff.d.ts +2 -6
- package/util/diff.js +1 -3
- package/util/files.d.ts +3 -9
- package/util/files.js +3 -9
- package/util/flowr-version.d.ts +2 -4
- package/util/flowr-version.js +3 -5
- package/util/html-hover-over.d.ts +1 -5
- package/util/html-hover-over.js +1 -5
- package/util/json.d.ts +1 -3
- package/util/json.js +1 -3
- package/util/log.d.ts +2 -1
- package/util/log.js +7 -14
- package/util/mermaid/ast.d.ts +3 -7
- package/util/mermaid/ast.js +2 -6
- package/util/mermaid/cfg.d.ts +2 -4
- package/util/mermaid/cfg.js +4 -8
- package/util/mermaid/dfg.d.ts +5 -15
- package/util/mermaid/dfg.js +20 -16
- package/util/mermaid/mermaid.d.ts +4 -13
- package/util/mermaid/mermaid.js +5 -19
- package/util/numbers.d.ts +1 -3
- package/util/numbers.js +1 -3
- package/util/objects.d.ts +4 -10
- package/util/objects.js +7 -6
- package/util/os.d.ts +1 -3
- package/util/os.js +1 -3
- package/util/parallel.d.ts +1 -4
- package/util/parallel.js +1 -4
- package/util/proc.js +2 -2
- package/util/quads.d.ts +6 -19
- package/util/quads.js +2 -7
- package/util/r-author.d.ts +1 -3
- package/util/r-author.js +2 -10
- package/util/r-license.d.ts +2 -6
- package/util/r-license.js +10 -43
- package/util/r-regex.d.ts +1 -3
- package/util/r-regex.js +1 -3
- package/util/r-value.d.ts +3 -9
- package/util/r-value.js +7 -21
- package/util/random.d.ts +1 -3
- package/util/random.js +1 -3
- package/util/range.d.ts +22 -66
- package/util/range.js +22 -66
- package/util/schema.d.ts +4 -13
- package/util/schema.js +4 -13
- package/util/simple-df/dfg-ascii.d.ts +1 -3
- package/util/simple-df/dfg-ascii.js +5 -27
- package/util/simple-df/dfg-view.d.ts +1 -3
- package/util/simple-df/dfg-view.js +1 -3
- package/util/slice-direction.d.ts +1 -3
- package/util/slice-direction.js +1 -3
- package/util/summarizer.d.ts +3 -8
- package/util/summarizer.js +1 -3
- package/util/text/ansi.d.ts +5 -15
- package/util/text/ansi.js +5 -15
- package/util/text/args.d.ts +8 -2
- package/util/text/args.js +41 -9
- package/util/text/playground-link.d.ts +9 -0
- package/util/text/playground-link.js +15 -11
- package/util/text/r-highlight.js +6 -6
- package/util/text/strings.d.ts +6 -19
- package/util/text/strings.js +7 -24
- package/util/text/time.d.ts +1 -3
- package/util/text/time.js +1 -3
- package/util/version.d.ts +3 -9
- package/util/version.js +4 -8
|
@@ -16,9 +16,7 @@ const r_fun_tab_1 = require("./r-fun-tab");
|
|
|
16
16
|
const log_1 = require("../../../../util/log");
|
|
17
17
|
const secure_mode_1 = require("../../../../util/secure-mode");
|
|
18
18
|
const rdaLog = log_1.log.getSubLogger({ name: 'flowr-rda-file' });
|
|
19
|
-
/**
|
|
20
|
-
* This decorates a text file and provides access to its content in the format of an {@link RObjectData}.
|
|
21
|
-
*/
|
|
19
|
+
/** This decorates a text file and provides access to its content in the format of an {@link RObjectData}. */
|
|
22
20
|
class FlowrRDAFile extends flowr_file_1.FlowrFile {
|
|
23
21
|
wrapped;
|
|
24
22
|
shortcut;
|
|
@@ -113,14 +111,12 @@ const SerializationMagic = {
|
|
|
113
111
|
'RDB3\n': SerializationTypeTag.MagicBinaryV3,
|
|
114
112
|
'RDX3\n': SerializationTypeTag.MagicXdrV3,
|
|
115
113
|
};
|
|
116
|
-
/** the format byte a bare serialization stream opens with, before its newline */
|
|
117
|
-
const BareStreamFormats = new Set(['A', 'B', 'X']);
|
|
118
114
|
/**
|
|
119
115
|
* Whether `buf` is a bare serialization stream rather than a saved workspace: an `.rds` written by `saveRDS`
|
|
120
116
|
* carries no `RDX3\n` magic and no pairlist of names, it starts straight at the format byte.
|
|
121
117
|
*/
|
|
122
118
|
function isBareSerializationStream(buf) {
|
|
123
|
-
return buf.length >= 2 && buf[1] === 0x0a &&
|
|
119
|
+
return buf.length >= 2 && buf[1] === 0x0a && SerializationFormatOfByte.has(String.fromCodePoint(buf[0]));
|
|
124
120
|
}
|
|
125
121
|
/** The control characters an ASCII-format string spells with a backslash escape; any other escaped character stands for itself. */
|
|
126
122
|
const AsciiEscapes = { n: '\n', t: '\t', v: '\v', b: '\b', r: '\r', f: '\f', a: '\x07' };
|
|
@@ -243,6 +239,18 @@ function bunzip(bzip2, content, limit = Infinity) {
|
|
|
243
239
|
}
|
|
244
240
|
return Buffer.concat(chunks);
|
|
245
241
|
}
|
|
242
|
+
/** the list-like SEXP types {@link RDAParser.VECTOR_ELT} and {@link RDAParser.SET_VECTOR_ELT} accept */
|
|
243
|
+
const ListSexpTypes = new Set([SexpType.VecSxp, SexpType.ExprSxp, SexpType.WeakRefSxp]);
|
|
244
|
+
/** the bytecode constant types {@link RDAParser.ReadBCLang} decodes as language objects */
|
|
245
|
+
const BCLangTypes = new Set([SexpType.LangSxp, SexpType.ListSxp, SexpType.BcRepDef, SexpType.BcRepRef, SexpType.AltLangSxp, SexpType.AttrListSxp]);
|
|
246
|
+
/** the base types an ALTREP object of an unregistered class is read back as, as a length zero vector */
|
|
247
|
+
const AltVecSexpTypes = new Set([
|
|
248
|
+
SexpType.LglSxp, SexpType.IntSxp, SexpType.RealSxp, SexpType.CplxSxp, SexpType.StrSxp, SexpType.RawSxp, SexpType.VecSxp, SexpType.ExprSxp
|
|
249
|
+
]);
|
|
250
|
+
/** the ASCII words that spell the special doubles */
|
|
251
|
+
const AsciiReals = new Map([['NA', RValues.NaReal], ['NaN', RValues.NaN], ['Inf', RValues.PosInf], ['-Inf', RValues.NegInf]]);
|
|
252
|
+
/** the format byte a serialization stream opens with */
|
|
253
|
+
const SerializationFormatOfByte = new Map([['A', SerializationFormat.Ascii], ['B', SerializationFormat.Binary], ['X', SerializationFormat.Xdr]]);
|
|
246
254
|
/**
|
|
247
255
|
* Parser for RDA files.
|
|
248
256
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c | R source: serialize.c}
|
|
@@ -252,16 +260,13 @@ class RDAParser {
|
|
|
252
260
|
file;
|
|
253
261
|
shortcut;
|
|
254
262
|
buffer;
|
|
255
|
-
currentDepth = 0;
|
|
256
263
|
offset = 0;
|
|
257
264
|
static R_CODE_SET_MAX = 2 ** 6 - 1;
|
|
258
|
-
RWeakRefs = null;
|
|
259
265
|
static SIZE_OF_DOUBLE = 2 ** 3;
|
|
260
266
|
static WORD_SIZE = 2 ** 7;
|
|
261
267
|
static MAX_VECTOR_LENGTH = 2 ** 16;
|
|
262
268
|
format;
|
|
263
269
|
refTable = [];
|
|
264
|
-
Registry = null;
|
|
265
270
|
constructor(file, shortcut = true) {
|
|
266
271
|
this.file = file;
|
|
267
272
|
this.shortcut = shortcut;
|
|
@@ -269,12 +274,7 @@ class RDAParser {
|
|
|
269
274
|
/** Decompresses, deserializes, and flattens (per the constructor's `shortcut`) the file. Answers found {@link RObjectData}s, `null` if the file is empty. */
|
|
270
275
|
parse() {
|
|
271
276
|
const result = this.parseObject();
|
|
272
|
-
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
return this.flattenRObject(result, this.shortcut);
|
|
277
|
-
}
|
|
277
|
+
return result === RValues.NilValue ? null : this.flattenRObject(result, this.shortcut);
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
280
|
* Parses the file into the single R object it serializes (what an `.rds` holds), without the flattening
|
|
@@ -290,20 +290,14 @@ class RDAParser {
|
|
|
290
290
|
* Throws Error if the file is of a recognized but unreadable kind. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/connections.c#L2675-L2710 | R source: comp_type_from_memory}
|
|
291
291
|
*/
|
|
292
292
|
detectCompression(buf, withZlib = false) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
else if ('unsupported' in signature) {
|
|
298
|
-
throw new Error(signature.unsupported);
|
|
299
|
-
}
|
|
300
|
-
return signature.type;
|
|
293
|
+
const signature = CompressionSignatures.find(s => startsWithMagic(buf, s.magic) && !('zlibOnly' in s && s.zlibOnly && !withZlib));
|
|
294
|
+
if (signature && 'unsupported' in signature) {
|
|
295
|
+
throw new Error(signature.unsupported);
|
|
301
296
|
}
|
|
302
|
-
return CompressionType.CompUnknownOrNo;
|
|
297
|
+
return signature?.type ?? CompressionType.CompUnknownOrNo;
|
|
303
298
|
}
|
|
304
299
|
/** Decompresses `fileContent` per the {@link detectCompression} result `compressionType`. Throws error for unsupported compression types. */
|
|
305
300
|
decompress(fileContent, compressionType) {
|
|
306
|
-
let buffer;
|
|
307
301
|
// the file belongs to the (possibly hostile) project, so the secure mode bounds what it may decompress to
|
|
308
302
|
const limit = secure_mode_1.SecureMode.decompressionLimit();
|
|
309
303
|
switch (compressionType) {
|
|
@@ -311,33 +305,27 @@ class RDAParser {
|
|
|
311
305
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- loaded on demand, so bundles without gzip files do not pull in zlib
|
|
312
306
|
const zlib = require('zlib');
|
|
313
307
|
try {
|
|
314
|
-
|
|
308
|
+
return zlib.gunzipSync(fileContent, { maxOutputLength: limit });
|
|
315
309
|
}
|
|
316
310
|
catch (e) {
|
|
317
311
|
if (e.code === 'ERR_BUFFER_TOO_LARGE') {
|
|
318
312
|
throw e;
|
|
319
313
|
}
|
|
320
|
-
|
|
314
|
+
return zlib.inflateSync(fileContent, { maxOutputLength: limit });
|
|
321
315
|
}
|
|
322
|
-
break;
|
|
323
316
|
}
|
|
324
|
-
case CompressionType.CompBz:
|
|
317
|
+
case CompressionType.CompBz:
|
|
325
318
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- the untyped `bzip2` package has no module declaration, and is loaded on demand
|
|
326
|
-
|
|
327
|
-
buffer = bunzip(bzip2, fileContent, limit);
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
319
|
+
return bunzip(require('bzip2'), fileContent, limit);
|
|
330
320
|
case CompressionType.CompXz:
|
|
331
321
|
case CompressionType.CompLzma:
|
|
332
322
|
case CompressionType.CompZstd:
|
|
333
323
|
throw new Error(`${compressionType} is not supported yet.`);
|
|
334
324
|
case CompressionType.CompUnknownOrNo:
|
|
335
|
-
|
|
336
|
-
break;
|
|
325
|
+
return fileContent;
|
|
337
326
|
default:
|
|
338
327
|
(0, assert_1.assertUnreachable)(compressionType);
|
|
339
328
|
}
|
|
340
|
-
return buffer;
|
|
341
329
|
}
|
|
342
330
|
/**
|
|
343
331
|
* Identifies the {@link SerializationTypes} of a decompressed RDA-file buffer.
|
|
@@ -345,22 +333,14 @@ class RDAParser {
|
|
|
345
333
|
*/
|
|
346
334
|
determineSerializationType(buf) {
|
|
347
335
|
if (buf.length < 5) {
|
|
348
|
-
|
|
349
|
-
return SerializationTypeTag.MagicEmpty;
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
return SerializationTypeTag.MagicCorrupt;
|
|
353
|
-
}
|
|
336
|
+
return buf.length === 0 ? SerializationTypeTag.MagicEmpty : SerializationTypeTag.MagicCorrupt;
|
|
354
337
|
}
|
|
355
338
|
const magic = buf.toString('ascii', 0, 5);
|
|
356
339
|
if (magic in SerializationMagic) {
|
|
357
340
|
return SerializationMagic[magic];
|
|
358
341
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
/* no magic at all: the first four bytes are the version number of a pre-magic workspace */
|
|
363
|
-
return Number(buf.toString('ascii', 0, 4));
|
|
342
|
+
/* without any magic, the first four bytes are the version number of a pre-magic workspace */
|
|
343
|
+
return magic.startsWith('RD') ? SerializationTypeTag.MagicMaybeTooNew : Number(buf.toString('ascii', 0, 4));
|
|
364
344
|
}
|
|
365
345
|
/**
|
|
366
346
|
* Deserializes a decompressed RDA-file. Answers {@link RObject}, or {@link RValues.NilValue} if deserialization fails.
|
|
@@ -374,9 +354,7 @@ class RDAParser {
|
|
|
374
354
|
}
|
|
375
355
|
const serializationType = this.determineSerializationType(this.buffer);
|
|
376
356
|
this.offset += 5;
|
|
377
|
-
if (
|
|
378
|
-
serializationType === SerializationTypeTag.MagicEmpty ||
|
|
379
|
-
serializationType === SerializationTypeTag.MagicMaybeTooNew) {
|
|
357
|
+
if ([SerializationTypeTag.MagicCorrupt, SerializationTypeTag.MagicEmpty, SerializationTypeTag.MagicMaybeTooNew].includes(serializationType)) {
|
|
380
358
|
throw new Error('Could not determine serialization type');
|
|
381
359
|
}
|
|
382
360
|
if (SupportedSerializationTypes.has(serializationType)) {
|
|
@@ -389,83 +367,62 @@ class RDAParser {
|
|
|
389
367
|
}
|
|
390
368
|
/** Deserializes a decompressed RDA-file. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2237-L2292 | R source: R_Unserialize} */
|
|
391
369
|
deserialize() {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
break;
|
|
402
|
-
case '\n':
|
|
403
|
-
/* an ASCII stream may leave a trailing newline behind, so the format follows in the next two bytes */
|
|
404
|
-
if (String.fromCodePoint(this.buffer[this.offset + 1]) !== 'A') {
|
|
405
|
-
throw new Error('unknown input format');
|
|
406
|
-
}
|
|
407
|
-
this.format = SerializationFormat.Ascii;
|
|
408
|
-
this.offset += 2;
|
|
409
|
-
break;
|
|
410
|
-
default:
|
|
411
|
-
throw new Error('unknown input format');
|
|
370
|
+
let formatByte = String.fromCodePoint(this.buffer[this.offset]);
|
|
371
|
+
/* an ASCII stream may leave a trailing newline behind, so the format follows in the next two bytes */
|
|
372
|
+
if (formatByte === '\n' && String.fromCodePoint(this.buffer[this.offset + 1]) === 'A') {
|
|
373
|
+
formatByte = 'A';
|
|
374
|
+
this.offset += 2;
|
|
375
|
+
}
|
|
376
|
+
const format = SerializationFormatOfByte.get(formatByte);
|
|
377
|
+
if (format === undefined) {
|
|
378
|
+
throw new Error('unknown input format');
|
|
412
379
|
}
|
|
380
|
+
this.format = format;
|
|
413
381
|
this.offset += 2;
|
|
414
|
-
const version = this.
|
|
415
|
-
const writerVersion = this.
|
|
416
|
-
const minReaderVersion = this.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
throw new Error(`cannot read unreleased workspace version ${version} written by experimental R ${vw}.${pw}.${sw}`);
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
const [vm, pm, sm] = this.decodeVersion(minReaderVersion);
|
|
436
|
-
throw new Error(`cannot read unreleased workspace version ${version} written by experimental R ${vw}.${pw}.${sw}; need R ${vm}.${pm}.${sm} or newer`);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
382
|
+
const version = this.readInt();
|
|
383
|
+
const writerVersion = this.readInt();
|
|
384
|
+
const minReaderVersion = this.readInt();
|
|
385
|
+
if (version === 3) {
|
|
386
|
+
const neLen = this.readInt();
|
|
387
|
+
if (neLen > RDAParser.R_CODE_SET_MAX || neLen < 0) {
|
|
388
|
+
throw new Error('invalid length of encoding name');
|
|
389
|
+
}
|
|
390
|
+
this.inString(neLen);
|
|
391
|
+
}
|
|
392
|
+
else if (version !== 2) {
|
|
393
|
+
const [vw, pw, sw] = this.decodeVersion(writerVersion);
|
|
394
|
+
const unreleased = `cannot read unreleased workspace version ${version} written by experimental R ${vw}.${pw}.${sw}`;
|
|
395
|
+
if (minReaderVersion < 0) {
|
|
396
|
+
throw new Error(unreleased);
|
|
397
|
+
}
|
|
398
|
+
const [vm, pm, sm] = this.decodeVersion(minReaderVersion);
|
|
399
|
+
throw new Error(`${unreleased}; need R ${vm}.${pm}.${sm} or newer`);
|
|
439
400
|
}
|
|
440
401
|
return this.readItem();
|
|
441
402
|
}
|
|
442
403
|
/** Reads a serialized integer. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L396-L420 | R source: inInteger} */
|
|
443
404
|
inInteger() {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return RValues.NaInteger;
|
|
449
|
-
}
|
|
450
|
-
const i = Number.parseInt(word, 10);
|
|
451
|
-
if (Number.isNaN(i)) {
|
|
452
|
-
throw new TypeError(`${word} (or ${i}) is not a number`);
|
|
453
|
-
}
|
|
454
|
-
return i;
|
|
455
|
-
}
|
|
456
|
-
case SerializationFormat.Binary: {
|
|
457
|
-
const i = this.buffer.readInt32LE(this.offset);
|
|
458
|
-
this.offset += 4;
|
|
459
|
-
return i;
|
|
405
|
+
if (this.format === SerializationFormat.Ascii) {
|
|
406
|
+
const word = this.inWord(128);
|
|
407
|
+
if (word === 'NA') {
|
|
408
|
+
return RValues.NaInteger;
|
|
460
409
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return i;
|
|
410
|
+
const i = Number.parseInt(word, 10);
|
|
411
|
+
if (Number.isNaN(i)) {
|
|
412
|
+
throw new TypeError(`${word} (or ${i}) is not a number`);
|
|
465
413
|
}
|
|
466
|
-
|
|
467
|
-
|
|
414
|
+
return i;
|
|
415
|
+
}
|
|
416
|
+
else if (this.format === SerializationFormat.Binary || this.format === SerializationFormat.Xdr) {
|
|
417
|
+
const i = this.format === SerializationFormat.Binary ? this.buffer.readInt32LE(this.offset) : this.buffer.readInt32BE(this.offset);
|
|
418
|
+
this.offset += 4;
|
|
419
|
+
return i;
|
|
468
420
|
}
|
|
421
|
+
return RValues.NaInteger;
|
|
422
|
+
}
|
|
423
|
+
/** Reads a serialized integer that must not be {@link RValues.NaInteger}. */
|
|
424
|
+
readInt() {
|
|
425
|
+
return this.assertInteger(this.inInteger());
|
|
469
426
|
}
|
|
470
427
|
/** Advances past a serialized integer. Mirrors {@link inInteger}. */
|
|
471
428
|
skipInteger() {
|
|
@@ -476,14 +433,14 @@ class RDAParser {
|
|
|
476
433
|
this.offset += 4;
|
|
477
434
|
}
|
|
478
435
|
}
|
|
479
|
-
|
|
436
|
+
/** . Throws error if `value` is {@link RValues.NaInteger}. */
|
|
480
437
|
assertInteger(value) {
|
|
481
438
|
if (value === RValues.NaInteger) {
|
|
482
439
|
throw new Error('Unexpected NA integer');
|
|
483
440
|
}
|
|
484
441
|
return value;
|
|
485
442
|
}
|
|
486
|
-
|
|
443
|
+
/** . Throws error if `obj` is {@link RValues.NilValue}. */
|
|
487
444
|
assertRObjectData(obj) {
|
|
488
445
|
if (obj === RValues.NilValue) {
|
|
489
446
|
throw new Error('Unexpected NilValue');
|
|
@@ -495,37 +452,30 @@ class RDAParser {
|
|
|
495
452
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L378-L394 | R source: inWord}
|
|
496
453
|
*/
|
|
497
454
|
inWord(size) {
|
|
498
|
-
let i = 0;
|
|
499
455
|
let c;
|
|
500
|
-
const word = new Array(size);
|
|
501
456
|
do {
|
|
502
457
|
c = this.inChar();
|
|
503
458
|
if (c === -1) {
|
|
504
459
|
throw new Error('Read character is -1.');
|
|
505
460
|
}
|
|
506
461
|
} while (this.isSpace(c));
|
|
507
|
-
|
|
508
|
-
|
|
462
|
+
let word = '';
|
|
463
|
+
while (!this.isSpace(c) && word.length < size) {
|
|
464
|
+
word += String.fromCodePoint(c);
|
|
509
465
|
c = this.inChar();
|
|
510
466
|
}
|
|
511
|
-
if (
|
|
512
|
-
throw new Error(`${
|
|
467
|
+
if (word.length >= size) {
|
|
468
|
+
throw new Error(`${word.length} >= ${size} when reading word.`);
|
|
513
469
|
}
|
|
514
|
-
return word
|
|
470
|
+
return word;
|
|
515
471
|
}
|
|
516
472
|
/** Skips an ASCII word. Mirrors {@link inWord}. Throws error on EOF or overflow past {@link RDAParser.WORD_SIZE}. */
|
|
517
473
|
skipWord() {
|
|
518
474
|
this.inWord(RDAParser.WORD_SIZE);
|
|
519
|
-
return '';
|
|
520
475
|
}
|
|
521
|
-
|
|
476
|
+
/** . Answers the next character, or `-1` on EOF. */
|
|
522
477
|
inChar() {
|
|
523
|
-
|
|
524
|
-
return -1;
|
|
525
|
-
}
|
|
526
|
-
const char = this.buffer[this.offset];
|
|
527
|
-
this.offset++;
|
|
528
|
-
return char;
|
|
478
|
+
return this.offset >= this.buffer.length ? -1 : this.buffer[this.offset++];
|
|
529
479
|
}
|
|
530
480
|
/** Whether `c` is a whitespace byte. */
|
|
531
481
|
isSpace(c) {
|
|
@@ -536,66 +486,45 @@ class RDAParser {
|
|
|
536
486
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L505-L550 | R source: inString}
|
|
537
487
|
*/
|
|
538
488
|
inString(len) {
|
|
539
|
-
if (this.format
|
|
540
|
-
if (len > 0) {
|
|
541
|
-
const result = [];
|
|
542
|
-
while (this.offset < this.buffer.length) {
|
|
543
|
-
const c = this.buffer[this.offset++];
|
|
544
|
-
if (!this.isSpace(c)) {
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
this.offset--;
|
|
549
|
-
for (let i = 0; i < len; i++) {
|
|
550
|
-
let c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
551
|
-
if (c === '\\') {
|
|
552
|
-
c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
553
|
-
switch (c) {
|
|
554
|
-
case 'n':
|
|
555
|
-
case 't':
|
|
556
|
-
case 'v':
|
|
557
|
-
case 'b':
|
|
558
|
-
case 'r':
|
|
559
|
-
case 'f':
|
|
560
|
-
case 'a':
|
|
561
|
-
result.push(AsciiEscapes[c]);
|
|
562
|
-
break;
|
|
563
|
-
case '0':
|
|
564
|
-
case '1':
|
|
565
|
-
case '2':
|
|
566
|
-
case '3':
|
|
567
|
-
case '4':
|
|
568
|
-
case '5':
|
|
569
|
-
case '6':
|
|
570
|
-
case '7': {
|
|
571
|
-
let d = 0;
|
|
572
|
-
let j = 0;
|
|
573
|
-
while ('0' <= c && c < '8' && j < 3) {
|
|
574
|
-
d = d * 8 + (Number.parseInt(c));
|
|
575
|
-
c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
576
|
-
j++;
|
|
577
|
-
}
|
|
578
|
-
result.push(String.fromCodePoint(d));
|
|
579
|
-
this.offset--;
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
default:
|
|
583
|
-
result.push(c);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
result.push(c);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
return result.join('');
|
|
591
|
-
}
|
|
592
|
-
return '';
|
|
593
|
-
}
|
|
594
|
-
else {
|
|
489
|
+
if (this.format !== SerializationFormat.Ascii) {
|
|
595
490
|
const bytes = this.buffer.subarray(this.offset, this.offset + len);
|
|
596
491
|
this.offset += len;
|
|
597
492
|
return bytes.toString('latin1');
|
|
598
493
|
}
|
|
494
|
+
else if (len <= 0) {
|
|
495
|
+
return '';
|
|
496
|
+
}
|
|
497
|
+
while (this.offset < this.buffer.length) {
|
|
498
|
+
if (!this.isSpace(this.buffer[this.offset++])) {
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
this.offset--;
|
|
503
|
+
const result = [];
|
|
504
|
+
for (let i = 0; i < len; i++) {
|
|
505
|
+
let c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
506
|
+
if (c !== '\\') {
|
|
507
|
+
result.push(c);
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
511
|
+
if (c in AsciiEscapes) {
|
|
512
|
+
result.push(AsciiEscapes[c]);
|
|
513
|
+
}
|
|
514
|
+
else if ('0' <= c && c < '8') {
|
|
515
|
+
let d = 0;
|
|
516
|
+
for (let j = 0; '0' <= c && c < '8' && j < 3; j++) {
|
|
517
|
+
d = d * 8 + Number.parseInt(c);
|
|
518
|
+
c = String.fromCodePoint(this.buffer[this.offset++]);
|
|
519
|
+
}
|
|
520
|
+
result.push(String.fromCodePoint(d));
|
|
521
|
+
this.offset--;
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
result.push(c);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return result.join('');
|
|
599
528
|
}
|
|
600
529
|
/** Skips a serialized string of `len` bytes. Mirrors {@link inString}. */
|
|
601
530
|
skipString(len) {
|
|
@@ -612,12 +541,8 @@ class RDAParser {
|
|
|
612
541
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2230-L2235 | R source: decodeVersion}
|
|
613
542
|
*/
|
|
614
543
|
decodeVersion(writerVersion) {
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
const p = Math.trunc(writerVersion / 2 ** 8);
|
|
618
|
-
writerVersion = writerVersion % 2 ** 8;
|
|
619
|
-
const s = writerVersion;
|
|
620
|
-
return [v, p, s];
|
|
544
|
+
const rest = writerVersion % RDAParser.MAX_VECTOR_LENGTH;
|
|
545
|
+
return [Math.trunc(writerVersion / RDAParser.MAX_VECTOR_LENGTH), Math.trunc(rest / 2 ** 8), rest % 2 ** 8];
|
|
621
546
|
}
|
|
622
547
|
/**
|
|
623
548
|
* Reads the next flags and dispatches to {@link readItemRecursive}; the main recursive entry point for every R
|
|
@@ -625,8 +550,11 @@ class RDAParser {
|
|
|
625
550
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2117-L2121 | R source: ReadItem}
|
|
626
551
|
*/
|
|
627
552
|
readItem() {
|
|
628
|
-
|
|
629
|
-
|
|
553
|
+
return this.readItemRecursive(this.readInt());
|
|
554
|
+
}
|
|
555
|
+
/** Reads the next item, or with `skip` advances past it via {@link skipItem}. */
|
|
556
|
+
nextItem(skip) {
|
|
557
|
+
return skip ? this.skipItem() : this.readItem();
|
|
630
558
|
}
|
|
631
559
|
/**
|
|
632
560
|
* Resolves a namespace reference by name. Simpler variant of {@link R_FindNamespace1}.
|
|
@@ -651,71 +579,46 @@ class RDAParser {
|
|
|
651
579
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1871-L2115 | R source: ReadItem_Recursive}
|
|
652
580
|
*/
|
|
653
581
|
readItemRecursive(flags) {
|
|
654
|
-
const [type, levels, object, hasAttribute
|
|
582
|
+
const [type, levels, object, hasAttribute] = this.unpackFlags(flags);
|
|
655
583
|
const special = SpecialValueSxps.get(type);
|
|
656
584
|
if (special) {
|
|
657
585
|
return { ...special };
|
|
658
586
|
}
|
|
659
|
-
let s;
|
|
660
587
|
switch (type) {
|
|
661
|
-
case SexpType.RefSxp:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
this.addReadRef(
|
|
665
|
-
return s;
|
|
666
|
-
}
|
|
588
|
+
case SexpType.RefSxp:
|
|
589
|
+
return this.getReadRef(this.inRefIndex(flags));
|
|
590
|
+
case SexpType.PersistSxp:
|
|
591
|
+
return this.addReadRef(this.inStringVec());
|
|
667
592
|
case SexpType.AltRepSxp:
|
|
668
593
|
rdaLog.warn('AltReps are not supported yet!');
|
|
669
594
|
return this.readOrSkipAltRep(object, levels, false);
|
|
670
595
|
case SexpType.SymSxp:
|
|
671
596
|
return this.readOrSkipSym(false);
|
|
672
597
|
case SexpType.PackageSxp:
|
|
673
|
-
|
|
674
|
-
s = this.inStringVec();
|
|
675
|
-
s = this.rFindPackageEnv(s);
|
|
676
|
-
this.addReadRef(s);
|
|
677
|
-
return s;
|
|
678
|
-
}
|
|
598
|
+
return this.addReadRef(this.rFindPackageEnv(this.inStringVec()));
|
|
679
599
|
case SexpType.NamespaceSxp:
|
|
680
|
-
|
|
681
|
-
s = this.R_FindNamespace1(s);
|
|
682
|
-
this.addReadRef(s);
|
|
683
|
-
return s;
|
|
600
|
+
return this.addReadRef(this.R_FindNamespace1(this.inStringVec()));
|
|
684
601
|
case SexpType.EnvSxp:
|
|
685
602
|
return this.readOrSkipEnv(false);
|
|
686
|
-
case SexpType.ListSxp:
|
|
687
|
-
case SexpType.LangSxp:
|
|
688
|
-
case SexpType.CloSxp:
|
|
689
|
-
case SexpType.PromSxp:
|
|
690
|
-
case SexpType.DotSxp:
|
|
691
|
-
return this.readItemIterative(flags);
|
|
692
603
|
default:
|
|
693
|
-
return this.readOrSkipLeaf(type, levels, object, hasAttribute, false);
|
|
604
|
+
return IterativeSexpTypes.has(type) ? this.readItemIterative(flags) : this.readOrSkipLeaf(type, levels, object, hasAttribute, false);
|
|
694
605
|
}
|
|
695
606
|
}
|
|
696
607
|
/** Reads (or with `skip`, discards) a `SymSxp` symbol. Shared by {@link readItemRecursive} and {@link skipItem}. */
|
|
697
608
|
readOrSkipSym(skip) {
|
|
698
|
-
this.currentDepth++;
|
|
699
609
|
const s = skip ? this.skipItem() : this.assertRObjectData(this.readItem());
|
|
700
|
-
this.currentDepth--;
|
|
701
610
|
s.type = SexpType.SymSxp;
|
|
702
|
-
this.addReadRef(s);
|
|
703
|
-
return s;
|
|
611
|
+
return this.addReadRef(s);
|
|
704
612
|
}
|
|
705
613
|
/**
|
|
706
614
|
* Reads (or with `skip`, discards) an `AltRepSxp`. Only `skip === false` attempts {@link AltRepUnserializeEx};
|
|
707
615
|
* discarding it just derives the base type its payload triple encodes. Shared by {@link readItemRecursive} and {@link skipItem}.
|
|
708
616
|
*/
|
|
709
617
|
readOrSkipAltRep(object, levels, skip) {
|
|
710
|
-
this.
|
|
711
|
-
const
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
const s = skip ?
|
|
715
|
-
{ type: info.cdr.cdr.car.type } :
|
|
716
|
-
this.AltRepUnserializeEx(info, state, attr, object, levels);
|
|
717
|
-
this.currentDepth--;
|
|
718
|
-
return s;
|
|
618
|
+
const info = this.nextItem(skip);
|
|
619
|
+
const state = this.nextItem(skip);
|
|
620
|
+
const attr = this.nextItem(skip);
|
|
621
|
+
return skip ? { type: info.cdr.cdr.car.type } : this.AltRepUnserializeEx(info, state, attr, object, levels);
|
|
719
622
|
}
|
|
720
623
|
/**
|
|
721
624
|
* Reads (or with `skip`, discards) an `EnvSxp` environment frame; the locked/class-object bookkeeping only matters when kept.
|
|
@@ -729,30 +632,19 @@ class RDAParser {
|
|
|
729
632
|
else {
|
|
730
633
|
locked = this.inInteger();
|
|
731
634
|
}
|
|
732
|
-
const s = { type: SexpType.EnvSxp };
|
|
733
|
-
this.
|
|
734
|
-
this.
|
|
735
|
-
|
|
736
|
-
s.
|
|
737
|
-
s.hashTab = skip ? this.skipItem() : this.readItem();
|
|
738
|
-
s.attributes = this.assertRObjectData(skip ? this.skipItem() : this.readItem()).attributes;
|
|
739
|
-
this.currentDepth--;
|
|
635
|
+
const s = this.addReadRef({ type: SexpType.EnvSxp });
|
|
636
|
+
this.SetEnClos(s, this.assertRObjectData(this.nextItem(skip)));
|
|
637
|
+
s.frame = this.nextItem(skip);
|
|
638
|
+
s.hashTab = this.nextItem(skip);
|
|
639
|
+
s.attributes = this.assertRObjectData(this.nextItem(skip)).attributes;
|
|
740
640
|
if (!skip) {
|
|
741
641
|
if (s.attributes?.some(e => e.name === RValues.ClassSymbol)) {
|
|
742
642
|
s._isObject = true;
|
|
743
643
|
}
|
|
744
|
-
// R_RestoreHashCount(s);
|
|
745
644
|
if (locked) {
|
|
746
645
|
s._isLocked = false;
|
|
747
646
|
}
|
|
748
647
|
}
|
|
749
|
-
if (!s.enClos || s.enClos === RValues.NilValue) {
|
|
750
|
-
this.SetEnClos(s, {
|
|
751
|
-
value: RValues.BaseEnv,
|
|
752
|
-
type: SexpType.EnvSxp,
|
|
753
|
-
enClos: RValues.NilValue
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
648
|
return s;
|
|
757
649
|
}
|
|
758
650
|
/**
|
|
@@ -762,27 +654,22 @@ class RDAParser {
|
|
|
762
654
|
readOrSkipLeaf(type, levels, object, hasAttribute, skip) {
|
|
763
655
|
let s = {};
|
|
764
656
|
switch (type) {
|
|
765
|
-
case SexpType.ExtPtrSxp:
|
|
657
|
+
case SexpType.ExtPtrSxp:
|
|
766
658
|
s.type = type;
|
|
767
659
|
this.addReadRef(s);
|
|
768
660
|
if (!skip) {
|
|
769
661
|
s.address = null;
|
|
770
662
|
}
|
|
771
|
-
this.
|
|
772
|
-
s.
|
|
773
|
-
s.tag = skip ? this.skipItem() : this.readItem();
|
|
774
|
-
this.currentDepth--;
|
|
663
|
+
s.protected = this.nextItem(skip);
|
|
664
|
+
s.tag = this.nextItem(skip);
|
|
775
665
|
break;
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const nilSxp = { type: SexpType.NilSxp, value: RValues.NilValue };
|
|
779
|
-
s.value = this.R_MakeWeakRef(nilSxp, RValues.NilValue, nilSxp, false);
|
|
666
|
+
case SexpType.WeakRefSxp:
|
|
667
|
+
s.value = { type: SexpType.WeakRefSxp };
|
|
780
668
|
this.addReadRef(s);
|
|
781
669
|
break;
|
|
782
|
-
}
|
|
783
670
|
case SexpType.SpecialSxp:
|
|
784
671
|
case SexpType.BuiltInSxp: {
|
|
785
|
-
const len = this.
|
|
672
|
+
const len = this.readInt();
|
|
786
673
|
if (len < 0) {
|
|
787
674
|
throw new Error('invalid length');
|
|
788
675
|
}
|
|
@@ -795,45 +682,33 @@ class RDAParser {
|
|
|
795
682
|
if (!(name in r_fun_tab_1.RFunTabOffsets)) {
|
|
796
683
|
throw new Error(`unrecognized internal function name "${name}"`);
|
|
797
684
|
}
|
|
798
|
-
|
|
799
|
-
s = this.mkPrimSxp(index, type === SexpType.BuiltInSxp ? 1 : 0);
|
|
685
|
+
s = this.mkPrimSxp(r_fun_tab_1.RFunTabOffsets[name], type === SexpType.BuiltInSxp ? 1 : 0);
|
|
800
686
|
}
|
|
801
687
|
break;
|
|
802
688
|
}
|
|
803
689
|
case SexpType.CharSxp: {
|
|
804
|
-
const len = this.
|
|
690
|
+
const len = this.readInt();
|
|
805
691
|
if (len < -1) {
|
|
806
692
|
throw new Error(`Invalid length ${len} of string.`);
|
|
807
693
|
}
|
|
808
|
-
|
|
809
|
-
s.name = RValues.NaString;
|
|
810
|
-
}
|
|
811
|
-
else {
|
|
812
|
-
s.name = this.readChar(len, levels);
|
|
813
|
-
}
|
|
694
|
+
s.name = len === -1 ? RValues.NaString : this.readChar(len, levels);
|
|
814
695
|
break;
|
|
815
696
|
}
|
|
816
697
|
case SexpType.LglSxp:
|
|
817
|
-
case SexpType.IntSxp:
|
|
818
|
-
const len = this.readLength();
|
|
819
|
-
s.type = type;
|
|
820
|
-
s.value = this.inIntegerVec(len, skip);
|
|
821
|
-
break;
|
|
822
|
-
}
|
|
698
|
+
case SexpType.IntSxp:
|
|
823
699
|
case SexpType.RealSxp: {
|
|
824
700
|
const len = this.readLength();
|
|
825
701
|
s.type = type;
|
|
826
|
-
s.value = this.inRealVec(len, skip);
|
|
702
|
+
s.value = type === SexpType.RealSxp ? this.inRealVec(len, skip) : this.inIntegerVec(len, skip);
|
|
827
703
|
break;
|
|
828
704
|
}
|
|
829
|
-
case SexpType.CplxSxp:
|
|
705
|
+
case SexpType.CplxSxp:
|
|
706
|
+
case SexpType.RawSxp: {
|
|
830
707
|
const len = this.readLength();
|
|
831
708
|
s.type = type;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
else {
|
|
836
|
-
s.value = this.inComplexVec(len);
|
|
709
|
+
const value = type === SexpType.CplxSxp ? this.inComplexVec(len, skip) : this.inRaw(len, skip);
|
|
710
|
+
if (!skip) {
|
|
711
|
+
s.value = value;
|
|
837
712
|
}
|
|
838
713
|
break;
|
|
839
714
|
}
|
|
@@ -842,24 +717,20 @@ class RDAParser {
|
|
|
842
717
|
case SexpType.ExprSxp: {
|
|
843
718
|
const len = this.readLength();
|
|
844
719
|
s.type = type;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
720
|
+
if (!skip) {
|
|
721
|
+
s.value = new Array(len);
|
|
722
|
+
}
|
|
723
|
+
for (let count = 0; count < len; ++count) {
|
|
724
|
+
if (skip) {
|
|
848
725
|
this.skipItem();
|
|
849
726
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
this.SET_STRING_ELT(s, count, this.assertRObjectData(this.readItem()));
|
|
856
|
-
}
|
|
857
|
-
else {
|
|
858
|
-
this.SET_VECTOR_ELT(s, count, this.readItem());
|
|
859
|
-
}
|
|
727
|
+
else if (type === SexpType.StrSxp) {
|
|
728
|
+
this.SET_STRING_ELT(s, count, this.assertRObjectData(this.readItem()));
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
this.SET_VECTOR_ELT(s, count, this.readItem());
|
|
860
732
|
}
|
|
861
733
|
}
|
|
862
|
-
this.currentDepth--;
|
|
863
734
|
break;
|
|
864
735
|
}
|
|
865
736
|
case SexpType.BcodesSxp:
|
|
@@ -875,17 +746,6 @@ class RDAParser {
|
|
|
875
746
|
throw new Error('this version of R cannot read class references');
|
|
876
747
|
case SexpType.GenericRefSxp:
|
|
877
748
|
throw new Error('this version of R cannot read generic function references');
|
|
878
|
-
case SexpType.RawSxp: {
|
|
879
|
-
const len = this.readLength();
|
|
880
|
-
s.type = type;
|
|
881
|
-
if (skip) {
|
|
882
|
-
this.inRaw(len, true);
|
|
883
|
-
}
|
|
884
|
-
else {
|
|
885
|
-
s.value = this.inRaw(len);
|
|
886
|
-
}
|
|
887
|
-
break;
|
|
888
|
-
}
|
|
889
749
|
case SexpType.ObjSxp:
|
|
890
750
|
s.type = SexpType.ObjSxp;
|
|
891
751
|
break;
|
|
@@ -898,70 +758,39 @@ class RDAParser {
|
|
|
898
758
|
}
|
|
899
759
|
s.object = object;
|
|
900
760
|
}
|
|
901
|
-
if (s.type
|
|
902
|
-
this.currentDepth++;
|
|
903
|
-
if (hasAttribute) {
|
|
904
|
-
if (skip) {
|
|
905
|
-
this.skipItem();
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
this.readItem();
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
this.currentDepth--;
|
|
912
|
-
}
|
|
913
|
-
else {
|
|
914
|
-
this.currentDepth++;
|
|
761
|
+
if (s.type !== SexpType.CharSxp) {
|
|
915
762
|
s.attributes = hasAttribute ? [skip ? this.skipItem() : this.assertRObjectData(this.readItem())] : undefined;
|
|
916
|
-
this.currentDepth--;
|
|
917
763
|
}
|
|
918
|
-
if (
|
|
919
|
-
|
|
764
|
+
else if (hasAttribute) {
|
|
765
|
+
this.nextItem(skip);
|
|
920
766
|
}
|
|
921
|
-
return s;
|
|
767
|
+
return !skip && s.type === SexpType.BcodesSxp ? this.R_BytecodeExpr(s) : s;
|
|
922
768
|
}
|
|
923
769
|
/** Advances past a serialized SEXP node, filling in only its type. Mirrors {@link readItemRecursive}'s structure, but skips payload data. */
|
|
924
770
|
skipItem() {
|
|
925
|
-
const flags = this.
|
|
926
|
-
const [type, levels, object, hasAttribute
|
|
927
|
-
|
|
771
|
+
const flags = this.readInt();
|
|
772
|
+
const [type, levels, object, hasAttribute] = this.unpackFlags(flags);
|
|
773
|
+
if (SpecialValueSxps.has(type)) {
|
|
774
|
+
return { type: SexpType.EnvSxp };
|
|
775
|
+
}
|
|
928
776
|
switch (type) {
|
|
929
|
-
case SexpType.NilValueSxp:
|
|
930
|
-
case SexpType.EmptyEnvSxp:
|
|
931
|
-
case SexpType.BaseEnvSxp:
|
|
932
|
-
case SexpType.GlobalEnvSxp:
|
|
933
|
-
case SexpType.UnboundValueSxp:
|
|
934
|
-
case SexpType.MissingArgSxp:
|
|
935
|
-
case SexpType.BaseNamespaceSxp:
|
|
936
|
-
s.type = SexpType.EnvSxp;
|
|
937
|
-
return s;
|
|
938
777
|
case SexpType.RefSxp:
|
|
939
778
|
return this.getReadRef(this.inRefIndex(flags));
|
|
940
779
|
case SexpType.NamespaceSxp:
|
|
941
780
|
this.inStringVec(true);
|
|
942
|
-
|
|
943
|
-
this.addReadRef(s);
|
|
944
|
-
return s;
|
|
781
|
+
return this.addReadRef({ type: SexpType.EnvSxp });
|
|
945
782
|
case SexpType.PackageSxp:
|
|
946
|
-
case SexpType.PersistSxp:
|
|
783
|
+
case SexpType.PersistSxp:
|
|
947
784
|
this.inStringVec(true);
|
|
948
|
-
|
|
949
|
-
return s;
|
|
950
|
-
}
|
|
785
|
+
return { type: SexpType.CharSxp };
|
|
951
786
|
case SexpType.AltRepSxp:
|
|
952
787
|
return this.readOrSkipAltRep(object, levels, true);
|
|
953
788
|
case SexpType.SymSxp:
|
|
954
789
|
return this.readOrSkipSym(true);
|
|
955
790
|
case SexpType.EnvSxp:
|
|
956
791
|
return this.readOrSkipEnv(true);
|
|
957
|
-
case SexpType.ListSxp:
|
|
958
|
-
case SexpType.LangSxp:
|
|
959
|
-
case SexpType.CloSxp:
|
|
960
|
-
case SexpType.PromSxp:
|
|
961
|
-
case SexpType.DotSxp:
|
|
962
|
-
return this.readItemIterative(flags);
|
|
963
792
|
default:
|
|
964
|
-
return this.readOrSkipLeaf(type, levels, object, hasAttribute, true);
|
|
793
|
+
return IterativeSexpTypes.has(type) ? this.readItemIterative(flags) : this.readOrSkipLeaf(type, levels, object, hasAttribute, true);
|
|
965
794
|
}
|
|
966
795
|
}
|
|
967
796
|
/**
|
|
@@ -969,26 +798,21 @@ class RDAParser {
|
|
|
969
798
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2062-L2084 | R source: ReadItem_Recursive}
|
|
970
799
|
*/
|
|
971
800
|
inRaw(len, skip = false) {
|
|
972
|
-
const result = [];
|
|
973
801
|
if (this.format === SerializationFormat.Ascii) {
|
|
802
|
+
const result = [];
|
|
974
803
|
for (let ix = 0; ix < len; ix++) {
|
|
975
804
|
if (skip) {
|
|
976
805
|
this.skipWord();
|
|
977
806
|
}
|
|
978
807
|
else {
|
|
979
|
-
result
|
|
808
|
+
result.push(Number.parseInt(this.inWord(128), 16));
|
|
980
809
|
}
|
|
981
810
|
}
|
|
982
811
|
return result;
|
|
983
812
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
for (let i = 0; i < len; i++) {
|
|
989
|
-
result[i] = this.buffer[this.offset++];
|
|
990
|
-
}
|
|
991
|
-
return result;
|
|
813
|
+
const start = this.offset;
|
|
814
|
+
this.offset += len;
|
|
815
|
+
return skip ? [] : Array.from({ length: len }, (_, i) => this.buffer[start + i]);
|
|
992
816
|
}
|
|
993
817
|
/** Resolves package environments. Not implemented yet!. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3732-L3741 | R source: R_FindPackageEnv} */
|
|
994
818
|
rFindPackageEnv(s) {
|
|
@@ -997,20 +821,14 @@ class RDAParser {
|
|
|
997
821
|
}
|
|
998
822
|
/** Decodes a raw SEXP flags word into `[type, levels, isObject, hasAttribute, hasTag]`. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L748-L756 | R source: UnpackFlags} */
|
|
999
823
|
unpackFlags(flags) {
|
|
1000
|
-
|
|
1001
|
-
const pLevels = flags >> 12;
|
|
1002
|
-
const pIsObj = (flags & (1 << 8)) !== 0;
|
|
1003
|
-
const pHasAttr = (flags & (1 << 9)) !== 0;
|
|
1004
|
-
const pHasTag = (flags & (1 << 10)) !== 0;
|
|
1005
|
-
return [pType, pLevels, pIsObj, pHasAttr, pHasTag];
|
|
824
|
+
return [flags & 255, flags >> 12, (flags & (1 << 8)) !== 0, (flags & (1 << 9)) !== 0, (flags & (1 << 10)) !== 0];
|
|
1006
825
|
}
|
|
1007
826
|
/** Retrieves the registered object at 1-based reference `index`. Throws error if out of range. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1461-L1469 | R source: GetReadRef} */
|
|
1008
827
|
getReadRef(index) {
|
|
1009
|
-
|
|
1010
|
-
if (i < 0 || i >= this.refTable.length) {
|
|
828
|
+
if (index < 1 || index > this.refTable.length) {
|
|
1011
829
|
throw new Error('reference index out of range');
|
|
1012
830
|
}
|
|
1013
|
-
return this.refTable[
|
|
831
|
+
return this.refTable[index - 1];
|
|
1014
832
|
}
|
|
1015
833
|
/**
|
|
1016
834
|
* The 1-based reference index encoded in `flags`: bits 8-31 encode it directly when non-zero, otherwise it is read as the next stream integer.
|
|
@@ -1018,16 +836,12 @@ class RDAParser {
|
|
|
1018
836
|
*/
|
|
1019
837
|
inRefIndex(flags) {
|
|
1020
838
|
const i = flags >> 8;
|
|
1021
|
-
|
|
1022
|
-
return this.assertInteger(this.inInteger());
|
|
1023
|
-
}
|
|
1024
|
-
else {
|
|
1025
|
-
return i;
|
|
1026
|
-
}
|
|
839
|
+
return i === 0 ? this.readInt() : i;
|
|
1027
840
|
}
|
|
1028
|
-
/** Appends `value` to the reference table so it can be resolved later by {@link getReadRef}. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1471-L1490 | R source: AddReadRef} */
|
|
841
|
+
/** Appends `value` to the reference table so it can be resolved later by {@link getReadRef}, and answers it. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1471-L1490 | R source: AddReadRef} */
|
|
1029
842
|
addReadRef(value) {
|
|
1030
843
|
this.refTable.push(value);
|
|
844
|
+
return value;
|
|
1031
845
|
}
|
|
1032
846
|
/**
|
|
1033
847
|
* Reads (or with `skip`, discards) a persistent string vector. Answers a `CharSxp` {@link RObjectData} whose
|
|
@@ -1038,20 +852,17 @@ class RDAParser {
|
|
|
1038
852
|
if (this.inInteger() !== 0) {
|
|
1039
853
|
throw new Error('names in persistent strings are not supported yet');
|
|
1040
854
|
}
|
|
1041
|
-
const len = this.
|
|
1042
|
-
const
|
|
1043
|
-
s.value = new Array(skip ? 0 : len);
|
|
1044
|
-
this.currentDepth++;
|
|
855
|
+
const len = this.readInt();
|
|
856
|
+
const value = new Array(skip ? 0 : len);
|
|
1045
857
|
for (let i = 0; i < len; i++) {
|
|
1046
858
|
if (skip) {
|
|
1047
859
|
this.skipItem();
|
|
1048
860
|
}
|
|
1049
861
|
else {
|
|
1050
|
-
|
|
862
|
+
value[i] = this.readItem();
|
|
1051
863
|
}
|
|
1052
864
|
}
|
|
1053
|
-
|
|
1054
|
-
return s;
|
|
865
|
+
return { type: SexpType.CharSxp, value };
|
|
1055
866
|
}
|
|
1056
867
|
/** Sets `x`'s enclosing environment to `v`. Throws error if `v` is invalid or would introduce a cycle. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L4677-L4690 | R source: SET_ENCLOS} */
|
|
1057
868
|
SetEnClos(x, v) {
|
|
@@ -1074,77 +885,31 @@ class RDAParser {
|
|
|
1074
885
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1800-L1868 | R source: ReadItem_Iterative}
|
|
1075
886
|
*/
|
|
1076
887
|
readItemIterative(flags) {
|
|
1077
|
-
let sFirst = null;
|
|
1078
|
-
let sLast = {};
|
|
1079
888
|
let type = flags & 255;
|
|
1080
889
|
if (!IterativeSexpTypes.has(type)) {
|
|
1081
890
|
throw new Error('Wrong type.');
|
|
1082
891
|
}
|
|
892
|
+
const head = {};
|
|
893
|
+
let last = head;
|
|
1083
894
|
while (IterativeSexpTypes.has(type)) {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
const s = { type, levels, object: isObject };
|
|
1087
|
-
this.currentDepth++;
|
|
895
|
+
const [, levels, object, hasAttr, hasTag] = this.unpackFlags(flags);
|
|
896
|
+
const s = { type, levels, object };
|
|
1088
897
|
s.attributes = hasAttr ? [this.shortcut ? this.skipItem() : this.assertRObjectData(this.readItem())] : undefined;
|
|
1089
898
|
s.tag = hasTag ? this.readItem() : RValues.NilValue;
|
|
1090
|
-
s.car = this.
|
|
1091
|
-
|
|
1092
|
-
if (sFirst === null) {
|
|
1093
|
-
sFirst = s;
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
sLast.cdr = s;
|
|
1097
|
-
}
|
|
1098
|
-
sLast = s;
|
|
1099
|
-
if (type === SexpType.CloSxp && (!s.enClos || s.cloEnv === RValues.NilValue)) {
|
|
899
|
+
s.car = this.nextItem(this.shortcut);
|
|
900
|
+
if (type === SexpType.CloSxp) {
|
|
1100
901
|
s.cloEnv = RValues.EmptyEnv;
|
|
1101
902
|
}
|
|
1102
|
-
else if (type === SexpType.PromSxp
|
|
903
|
+
else if (type === SexpType.PromSxp) {
|
|
1103
904
|
s.prEnv = RValues.BaseEnv;
|
|
1104
905
|
}
|
|
1105
|
-
|
|
906
|
+
last.cdr = s;
|
|
907
|
+
last = s;
|
|
908
|
+
flags = this.readInt();
|
|
1106
909
|
type = flags & 255;
|
|
1107
910
|
}
|
|
1108
|
-
this.
|
|
1109
|
-
|
|
1110
|
-
this.currentDepth--;
|
|
1111
|
-
sLast.cdr = s;
|
|
1112
|
-
return sFirst;
|
|
1113
|
-
}
|
|
1114
|
-
/** Creates a weak reference object. Throws error if `fin` is not a function or NULL. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L1424-L1435 | R source: R_MakeWeakRef} */
|
|
1115
|
-
R_MakeWeakRef(key, val, fin, onexit) {
|
|
1116
|
-
switch (fin.type) {
|
|
1117
|
-
case SexpType.NilSxp:
|
|
1118
|
-
case SexpType.CloSxp:
|
|
1119
|
-
case SexpType.BuiltInSxp:
|
|
1120
|
-
case SexpType.SpecialSxp:
|
|
1121
|
-
break;
|
|
1122
|
-
default:
|
|
1123
|
-
throw new Error('finalizer must be a function or NULL');
|
|
1124
|
-
}
|
|
1125
|
-
return this.newWeakRef(key, val, fin, onexit);
|
|
1126
|
-
}
|
|
1127
|
-
/** Allocates and initializes a weak reference object. Throws error if `key`'s type is invalid. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L1388-L1422 | R source: NewWeakRef} */
|
|
1128
|
-
newWeakRef(key, val, fin, _onexit) {
|
|
1129
|
-
switch (key.type) {
|
|
1130
|
-
case SexpType.NilSxp:
|
|
1131
|
-
case SexpType.EnvSxp:
|
|
1132
|
-
case SexpType.ExtPtrSxp:
|
|
1133
|
-
case SexpType.BcodesSxp:
|
|
1134
|
-
break;
|
|
1135
|
-
default:
|
|
1136
|
-
throw new Error('can only weakly reference/finalize reference objects');
|
|
1137
|
-
}
|
|
1138
|
-
const w = { type: SexpType.WeakRefSxp };
|
|
1139
|
-
if (key.value !== RValues.NilValue) {
|
|
1140
|
-
w.key = key;
|
|
1141
|
-
w.value = val;
|
|
1142
|
-
w.finalizer = fin;
|
|
1143
|
-
w.next = this.RWeakRefs;
|
|
1144
|
-
// gp bitflag bookkeeping omitted: gp is never populated on a freshly built RObjectData, so it was always a no-op
|
|
1145
|
-
this.RWeakRefs = w;
|
|
1146
|
-
}
|
|
1147
|
-
return w;
|
|
911
|
+
last.cdr = this.readItemRecursive(flags);
|
|
912
|
+
return head.cdr;
|
|
1148
913
|
}
|
|
1149
914
|
/**
|
|
1150
915
|
* Creates or retrieves a cached primitive function object of type {@link SexpType.BuiltInSxp} (`evaluation` non-zero)
|
|
@@ -1155,10 +920,7 @@ class RDAParser {
|
|
|
1155
920
|
if (index < 0 || index >= Object.keys(r_fun_tab_1.RFunTabOffsets).length) {
|
|
1156
921
|
throw new Error('offset is out of R_FunTab range');
|
|
1157
922
|
}
|
|
1158
|
-
return {
|
|
1159
|
-
type: evaluation ? SexpType.BuiltInSxp : SexpType.SpecialSxp,
|
|
1160
|
-
offset: index
|
|
1161
|
-
};
|
|
923
|
+
return { type: evaluation ? SexpType.BuiltInSxp : SexpType.SpecialSxp, offset: index };
|
|
1162
924
|
}
|
|
1163
925
|
/**
|
|
1164
926
|
* Reads `len` bytes as a character string, decoded per the encoding flags in `levels` (bit 3 UTF-8, bit 2 Latin-1,
|
|
@@ -1166,15 +928,14 @@ class RDAParser {
|
|
|
1166
928
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1689-L1759 | R source: ReadChar}
|
|
1167
929
|
*/
|
|
1168
930
|
readChar(len, levels) {
|
|
1169
|
-
const
|
|
1170
|
-
const bytes = Buffer.from(cBuf, 'latin1');
|
|
931
|
+
const bytes = Buffer.from(this.inString(len), 'latin1');
|
|
1171
932
|
if (levels & (1 << 3)) {
|
|
1172
933
|
return new TextDecoder('utf-8').decode(bytes);
|
|
1173
934
|
}
|
|
1174
|
-
if (levels & (1 << 2)) {
|
|
935
|
+
else if (levels & (1 << 2)) {
|
|
1175
936
|
return new TextDecoder('iso-8859-1').decode(bytes);
|
|
1176
937
|
}
|
|
1177
|
-
if (levels & (1 << 1) || levels & (1 << 6)) {
|
|
938
|
+
else if (levels & (1 << 1) || levels & (1 << 6)) {
|
|
1178
939
|
return bytes.toString('latin1');
|
|
1179
940
|
}
|
|
1180
941
|
rdaLog.warn('Native encoding detected! Native encoding not supported yet! Value will be empty');
|
|
@@ -1185,137 +946,91 @@ class RDAParser {
|
|
|
1185
946
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1761-L1782 | R source: ReadLENGTH}
|
|
1186
947
|
*/
|
|
1187
948
|
readLength() {
|
|
1188
|
-
const len = this.
|
|
949
|
+
const len = this.readInt();
|
|
1189
950
|
if (len < -1) {
|
|
1190
951
|
throw new Error('negative serialized length for vector');
|
|
1191
952
|
}
|
|
1192
|
-
if (len
|
|
1193
|
-
const len1 = this.assertInteger(this.inInteger());
|
|
1194
|
-
const len2 = this.assertInteger(this.inInteger());
|
|
1195
|
-
/* sanity check for now */
|
|
1196
|
-
if (len1 > RDAParser.MAX_VECTOR_LENGTH) {
|
|
1197
|
-
throw new Error('invalid upper part of serialized vector length');
|
|
1198
|
-
}
|
|
1199
|
-
/* both halves are written as unsigned; a shift would wrap at 32 bit, so the high half is scaled instead */
|
|
1200
|
-
return len1 * 2 ** 32 + (len2 >>> 0);
|
|
1201
|
-
}
|
|
1202
|
-
else {
|
|
953
|
+
else if (len !== -1) {
|
|
1203
954
|
return len;
|
|
1204
955
|
}
|
|
956
|
+
const len1 = this.readInt();
|
|
957
|
+
const len2 = this.readInt();
|
|
958
|
+
if (len1 > RDAParser.MAX_VECTOR_LENGTH) {
|
|
959
|
+
throw new Error('invalid upper part of serialized vector length');
|
|
960
|
+
}
|
|
961
|
+
/* both halves are written as unsigned; a shift would wrap at 32 bit, so the high half is scaled instead */
|
|
962
|
+
return len1 * 2 ** 32 + (len2 >>> 0);
|
|
1205
963
|
}
|
|
1206
964
|
/**
|
|
1207
965
|
* Reads (or with `skip`, discards) `len` integers. Throws Error for BINARY format or XDR buffer overrun.
|
|
1208
966
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1507-L1541 | R source: InIntegerVec}
|
|
1209
967
|
*/
|
|
1210
968
|
inIntegerVec(len, skip = false) {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
this.offset += 4 * len;
|
|
1218
|
-
return [];
|
|
1219
|
-
}
|
|
1220
|
-
const result = [];
|
|
1221
|
-
for (let cnt = 0; cnt < len; cnt++) {
|
|
1222
|
-
result[cnt] = this.buffer.readInt32BE(this.offset);
|
|
1223
|
-
this.offset += 4;
|
|
1224
|
-
}
|
|
1225
|
-
return result;
|
|
969
|
+
if (this.format === SerializationFormat.Binary) {
|
|
970
|
+
throw new Error('No binary support yet.');
|
|
971
|
+
}
|
|
972
|
+
else if (this.format === SerializationFormat.Xdr) {
|
|
973
|
+
if (this.offset + 4 * len > this.buffer.length) {
|
|
974
|
+
throw new Error('XDR read failed');
|
|
1226
975
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
}
|
|
1239
|
-
return skip ? [] : result;
|
|
976
|
+
const start = this.offset;
|
|
977
|
+
this.offset += 4 * len;
|
|
978
|
+
return skip ? [] : Array.from({ length: len }, (_, i) => this.buffer.readInt32BE(start + 4 * i));
|
|
979
|
+
}
|
|
980
|
+
const result = [];
|
|
981
|
+
for (let cnt = 0; cnt < len; cnt++) {
|
|
982
|
+
if (skip) {
|
|
983
|
+
this.skipInteger();
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
result.push(this.inInteger());
|
|
1240
987
|
}
|
|
1241
988
|
}
|
|
989
|
+
return result;
|
|
1242
990
|
}
|
|
1243
991
|
/**
|
|
1244
992
|
* Reads (or with `skip`, discards) `len` doubles. Throws Error for BINARY format.
|
|
1245
993
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1543-L1577 | R source: InRealVec}
|
|
1246
994
|
*/
|
|
1247
995
|
inRealVec(len, skip = false) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
if (skip) {
|
|
1251
|
-
this.offset += len * RDAParser.SIZE_OF_DOUBLE;
|
|
1252
|
-
return [];
|
|
1253
|
-
}
|
|
1254
|
-
const result = [];
|
|
1255
|
-
for (let i = 0; i < len; i++) {
|
|
1256
|
-
result.push(this.buffer.readDoubleBE(this.offset));
|
|
1257
|
-
this.offset += RDAParser.SIZE_OF_DOUBLE;
|
|
1258
|
-
}
|
|
1259
|
-
return result;
|
|
1260
|
-
}
|
|
1261
|
-
case SerializationFormat.Binary:
|
|
1262
|
-
throw new Error('No binary support yet.');
|
|
1263
|
-
default: {
|
|
1264
|
-
const result = [];
|
|
1265
|
-
for (let cnt = 0; cnt < len; cnt++) {
|
|
1266
|
-
if (skip) {
|
|
1267
|
-
this.inReal(true);
|
|
1268
|
-
}
|
|
1269
|
-
else {
|
|
1270
|
-
result[cnt] = this.inReal();
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return skip ? [] : result;
|
|
1274
|
-
}
|
|
996
|
+
if (this.format === SerializationFormat.Binary) {
|
|
997
|
+
throw new Error('No binary support yet.');
|
|
1275
998
|
}
|
|
999
|
+
else if (this.format === SerializationFormat.Xdr) {
|
|
1000
|
+
const start = this.offset;
|
|
1001
|
+
this.offset += len * RDAParser.SIZE_OF_DOUBLE;
|
|
1002
|
+
return skip ? [] : Array.from({ length: len }, (_, i) => this.buffer.readDoubleBE(start + i * RDAParser.SIZE_OF_DOUBLE));
|
|
1003
|
+
}
|
|
1004
|
+
const result = Array.from({ length: len }, () => this.inReal(skip));
|
|
1005
|
+
return skip ? [] : result;
|
|
1276
1006
|
}
|
|
1277
1007
|
/**
|
|
1278
1008
|
* Reads (or with `skip`, discards) the next double. Throws TypeError if the ASCII token is not a valid float.
|
|
1279
1009
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L427-L463 | R source: InReal}
|
|
1280
1010
|
*/
|
|
1281
1011
|
inReal(skip = false) {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
return RValues.NilValue;
|
|
1287
|
-
}
|
|
1288
|
-
const word = this.inWord(128);
|
|
1289
|
-
if (word === 'NA') {
|
|
1290
|
-
return RValues.NaReal;
|
|
1291
|
-
}
|
|
1292
|
-
else if (word === 'NaN') {
|
|
1293
|
-
return RValues.NaN;
|
|
1294
|
-
}
|
|
1295
|
-
else if (word === 'Inf') {
|
|
1296
|
-
return RValues.PosInf;
|
|
1297
|
-
}
|
|
1298
|
-
else if (word === '-Inf') {
|
|
1299
|
-
return RValues.NegInf;
|
|
1300
|
-
}
|
|
1301
|
-
else {
|
|
1302
|
-
const d = Number.parseFloat(word);
|
|
1303
|
-
if (Number.isNaN(d)) {
|
|
1304
|
-
throw new TypeError('Read error: Invalid numeric ASCII format');
|
|
1305
|
-
}
|
|
1306
|
-
return d;
|
|
1307
|
-
}
|
|
1012
|
+
if (this.format === SerializationFormat.Ascii) {
|
|
1013
|
+
if (skip) {
|
|
1014
|
+
this.skipWord();
|
|
1015
|
+
return RValues.NilValue;
|
|
1308
1016
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
this.offset += 8;
|
|
1314
|
-
return d;
|
|
1017
|
+
const word = this.inWord(128);
|
|
1018
|
+
const special = AsciiReals.get(word);
|
|
1019
|
+
if (special !== undefined) {
|
|
1020
|
+
return special;
|
|
1315
1021
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1022
|
+
const d = Number.parseFloat(word);
|
|
1023
|
+
if (Number.isNaN(d)) {
|
|
1024
|
+
throw new TypeError('Read error: Invalid numeric ASCII format');
|
|
1025
|
+
}
|
|
1026
|
+
return d;
|
|
1027
|
+
}
|
|
1028
|
+
else if (this.format === SerializationFormat.Binary || this.format === SerializationFormat.Xdr) {
|
|
1029
|
+
const d = skip ? RValues.NilValue : this.format === SerializationFormat.Binary ? this.buffer.readDoubleLE(this.offset) : this.buffer.readDoubleBE(this.offset);
|
|
1030
|
+
this.offset += 8;
|
|
1031
|
+
return d;
|
|
1318
1032
|
}
|
|
1033
|
+
return RValues.NilValue;
|
|
1319
1034
|
}
|
|
1320
1035
|
/**
|
|
1321
1036
|
* Reads (or with `skip`, discards) `len` complex numbers, each as two consecutive doubles via {@link inComplex}. Throws Error for BINARY format.
|
|
@@ -1325,10 +1040,7 @@ class RDAParser {
|
|
|
1325
1040
|
if (this.format === SerializationFormat.Binary) {
|
|
1326
1041
|
throw new Error('No binary support yet.');
|
|
1327
1042
|
}
|
|
1328
|
-
const result =
|
|
1329
|
-
for (let cnt = 0; cnt < len; cnt++) {
|
|
1330
|
-
result[cnt] = this.inComplex(skip);
|
|
1331
|
-
}
|
|
1043
|
+
const result = Array.from({ length: len }, () => this.inComplex(skip));
|
|
1332
1044
|
return skip ? [] : result;
|
|
1333
1045
|
}
|
|
1334
1046
|
/**
|
|
@@ -1357,20 +1069,18 @@ class RDAParser {
|
|
|
1357
1069
|
* is not a list type or `i` is out of bounds. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L4303-L4322 | R source: SET_VECTOR_ELT}
|
|
1358
1070
|
*/
|
|
1359
1071
|
SET_VECTOR_ELT(x, i, v) {
|
|
1360
|
-
if (x.type
|
|
1361
|
-
x.type !== SexpType.ExprSxp &&
|
|
1362
|
-
x.type !== SexpType.WeakRefSxp) {
|
|
1072
|
+
if (!ListSexpTypes.has(x.type)) {
|
|
1363
1073
|
throw new Error(`SET_VECTOR_ELT() can only be applied to a 'list', not a '${x.type}'`);
|
|
1364
1074
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1075
|
+
const arr = x.value;
|
|
1076
|
+
if (i < 0 || i >= arr.length) {
|
|
1077
|
+
throw new Error(`attempt to set index ${i}/${arr.length} in SET_VECTOR_ELT`);
|
|
1367
1078
|
}
|
|
1368
|
-
|
|
1079
|
+
arr[i] = v;
|
|
1369
1080
|
}
|
|
1370
1081
|
/** Deserializes an R bytecode object. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2221-L2228 | R source: ReadBC} */
|
|
1371
1082
|
readBC() {
|
|
1372
|
-
|
|
1373
|
-
return this.readBC1(reps);
|
|
1083
|
+
return this.readBC1({ type: SexpType.VecSxp, value: new Array(this.readInt()) });
|
|
1374
1084
|
}
|
|
1375
1085
|
/** Advances past a bytecode object. Mirrors {@link readBC}. */
|
|
1376
1086
|
skipBC() {
|
|
@@ -1379,193 +1089,97 @@ class RDAParser {
|
|
|
1379
1089
|
}
|
|
1380
1090
|
/** Advances past a single bytecode. Mirrors {@link readBC1}. */
|
|
1381
1091
|
skipBC1() {
|
|
1382
|
-
this.currentDepth++;
|
|
1383
1092
|
this.skipItem();
|
|
1384
|
-
this.currentDepth--;
|
|
1385
1093
|
this.readOrSkipBCConsts(undefined, true);
|
|
1386
1094
|
}
|
|
1387
|
-
/**
|
|
1388
|
-
* Registers a bytecode object after encoding.
|
|
1389
|
-
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L8820-L8885 | R source: R_registerBC}
|
|
1390
|
-
*/
|
|
1391
|
-
R_registerBC(_bytes, _s) {
|
|
1392
|
-
throw new Error('BC not implemented yet');
|
|
1393
|
-
}
|
|
1394
1095
|
/** Deserializes a single bytecode object, `reps` is the repetition table shared across all constants. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2205-L2219 | R source: ReadBC1} */
|
|
1395
1096
|
readBC1(reps) {
|
|
1396
|
-
|
|
1397
|
-
this.currentDepth++;
|
|
1398
|
-
s.car = this.readItem();
|
|
1399
|
-
this.currentDepth--;
|
|
1400
|
-
// s.car = R_bcEncode(bytes);
|
|
1401
|
-
s.cdr = this.readOrSkipBCConsts(reps, false);
|
|
1402
|
-
s.tag = RValues.NilValue;
|
|
1403
|
-
// R_registerBC(bytes, s);
|
|
1404
|
-
return s;
|
|
1405
|
-
}
|
|
1406
|
-
/** Encodes bytecode instructions. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L8723-L8771 | R source: R_bcEncode} */
|
|
1407
|
-
_R_bcEncode(_bytes) {
|
|
1408
|
-
throw new Error('Not implemented');
|
|
1097
|
+
return { type: SexpType.BcodesSxp, car: this.readItem(), cdr: this.readOrSkipBCConsts(reps, false), tag: RValues.NilValue };
|
|
1409
1098
|
}
|
|
1410
1099
|
/**
|
|
1411
1100
|
* Reads (or with `skip`, discards) the `n` constants of a bytecode object into a `VecSxp`, `reps` resolves `BcRepDef`/`BcRepRef`.
|
|
1412
1101
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2173-L2203 | R source: ReadBCConsts}
|
|
1413
1102
|
*/
|
|
1414
1103
|
readOrSkipBCConsts(reps, skip) {
|
|
1415
|
-
const n = this.
|
|
1104
|
+
const n = this.readInt();
|
|
1416
1105
|
const ans = { type: SexpType.VecSxp, value: new Array(n) };
|
|
1417
1106
|
for (let i = 0; i < n; i++) {
|
|
1418
1107
|
const type = this.inInteger();
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
case SexpType.BcRepDef:
|
|
1431
|
-
case SexpType.BcRepRef:
|
|
1432
|
-
case SexpType.AltLangSxp:
|
|
1433
|
-
case SexpType.AttrListSxp:
|
|
1434
|
-
if (skip) {
|
|
1435
|
-
this.skipBCLang(type);
|
|
1436
|
-
}
|
|
1437
|
-
else {
|
|
1438
|
-
this.SET_VECTOR_ELT(ans, i, this.ReadBCLang(type, reps));
|
|
1439
|
-
}
|
|
1440
|
-
break;
|
|
1441
|
-
default:
|
|
1442
|
-
this.currentDepth++;
|
|
1443
|
-
if (skip) {
|
|
1444
|
-
this.skipItem();
|
|
1445
|
-
}
|
|
1446
|
-
else {
|
|
1447
|
-
this.SET_VECTOR_ELT(ans, i, this.readItem());
|
|
1448
|
-
}
|
|
1449
|
-
this.currentDepth--;
|
|
1108
|
+
if (!skip) {
|
|
1109
|
+
this.SET_VECTOR_ELT(ans, i, type === SexpType.BcodesSxp ? this.readBC1(reps) : BCLangTypes.has(type) ? this.ReadBCLang(type, reps) : this.readItem());
|
|
1110
|
+
}
|
|
1111
|
+
else if (type === SexpType.BcodesSxp) {
|
|
1112
|
+
this.skipBC1();
|
|
1113
|
+
}
|
|
1114
|
+
else if (BCLangTypes.has(type)) {
|
|
1115
|
+
this.skipBCLang(type);
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
this.skipItem();
|
|
1450
1119
|
}
|
|
1451
1120
|
}
|
|
1452
1121
|
return ans;
|
|
1453
1122
|
}
|
|
1454
1123
|
/** Reads a single language object from bytecode constants, `reps` is the shared repetition table. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2125-L2171 | R source: ReadBCLang} */
|
|
1455
1124
|
ReadBCLang(type, reps) {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
case SexpType.ListSxp:
|
|
1462
|
-
case SexpType.AltLangSxp:
|
|
1463
|
-
case SexpType.AttrListSxp:
|
|
1464
|
-
{
|
|
1465
|
-
let pos = -1;
|
|
1466
|
-
let hasAttr = false;
|
|
1467
|
-
if (type == SexpType.BcRepDef) {
|
|
1468
|
-
pos = this.assertInteger(this.inInteger());
|
|
1469
|
-
type = this.assertInteger(this.inInteger());
|
|
1470
|
-
}
|
|
1471
|
-
switch (type) {
|
|
1472
|
-
case SexpType.AltLangSxp:
|
|
1473
|
-
type = SexpType.LangSxp;
|
|
1474
|
-
hasAttr = true;
|
|
1475
|
-
break;
|
|
1476
|
-
case SexpType.AttrListSxp:
|
|
1477
|
-
type = SexpType.ListSxp;
|
|
1478
|
-
hasAttr = true;
|
|
1479
|
-
break;
|
|
1480
|
-
}
|
|
1481
|
-
const ans = {};
|
|
1482
|
-
ans.type = type;
|
|
1483
|
-
if (pos >= 0) {
|
|
1484
|
-
this.SET_VECTOR_ELT(reps, pos, ans);
|
|
1485
|
-
}
|
|
1486
|
-
this.currentDepth++;
|
|
1487
|
-
if (hasAttr) {
|
|
1488
|
-
ans.attributes ??= [];
|
|
1489
|
-
ans.attributes.push(this.assertRObjectData(this.readItem()));
|
|
1490
|
-
}
|
|
1491
|
-
ans.tag = this.readItem();
|
|
1492
|
-
this.currentDepth--;
|
|
1493
|
-
ans.car = this.ReadBCLang(this.assertInteger(this.inInteger()), reps);
|
|
1494
|
-
ans.cdr = this.ReadBCLang(this.assertInteger(this.inInteger()), reps);
|
|
1495
|
-
return ans;
|
|
1496
|
-
}
|
|
1497
|
-
default:
|
|
1498
|
-
{
|
|
1499
|
-
this.currentDepth++;
|
|
1500
|
-
const res = this.readItem();
|
|
1501
|
-
this.currentDepth--;
|
|
1502
|
-
return res;
|
|
1503
|
-
}
|
|
1125
|
+
if (type === SexpType.BcRepRef) {
|
|
1126
|
+
return this.VECTOR_ELT(reps, this.readInt());
|
|
1127
|
+
}
|
|
1128
|
+
else if (!BCLangTypes.has(type)) {
|
|
1129
|
+
return this.readItem();
|
|
1504
1130
|
}
|
|
1131
|
+
let pos = -1;
|
|
1132
|
+
if (type === SexpType.BcRepDef) {
|
|
1133
|
+
pos = this.readInt();
|
|
1134
|
+
type = this.readInt();
|
|
1135
|
+
}
|
|
1136
|
+
const hasAttr = type === SexpType.AltLangSxp || type === SexpType.AttrListSxp;
|
|
1137
|
+
const ans = { type: type === SexpType.AltLangSxp ? SexpType.LangSxp : type === SexpType.AttrListSxp ? SexpType.ListSxp : type };
|
|
1138
|
+
if (pos >= 0) {
|
|
1139
|
+
this.SET_VECTOR_ELT(reps, pos, ans);
|
|
1140
|
+
}
|
|
1141
|
+
if (hasAttr) {
|
|
1142
|
+
ans.attributes = [this.assertRObjectData(this.readItem())];
|
|
1143
|
+
}
|
|
1144
|
+
ans.tag = this.readItem();
|
|
1145
|
+
ans.car = this.ReadBCLang(this.readInt(), reps);
|
|
1146
|
+
ans.cdr = this.ReadBCLang(this.readInt(), reps);
|
|
1147
|
+
return ans;
|
|
1505
1148
|
}
|
|
1506
1149
|
/** Advances past a single language object. Mirrors {@link ReadBCLang}. */
|
|
1507
1150
|
skipBCLang(type) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
}
|
|
1523
|
-
if (type === SexpType.AltLangSxp || type === SexpType.AttrListSxp) {
|
|
1524
|
-
hasAttr = true;
|
|
1525
|
-
}
|
|
1526
|
-
this.currentDepth++;
|
|
1527
|
-
if (hasAttr) {
|
|
1528
|
-
this.skipItem();
|
|
1529
|
-
}
|
|
1530
|
-
this.readItem();
|
|
1531
|
-
this.skipItem();
|
|
1532
|
-
this.currentDepth--;
|
|
1533
|
-
this.skipBCLang(this.assertInteger(this.inInteger()));
|
|
1534
|
-
this.skipBCLang(this.assertInteger(this.inInteger()));
|
|
1535
|
-
break;
|
|
1536
|
-
}
|
|
1537
|
-
default:
|
|
1538
|
-
{
|
|
1539
|
-
this.currentDepth++;
|
|
1540
|
-
this.skipItem();
|
|
1541
|
-
this.currentDepth--;
|
|
1542
|
-
}
|
|
1151
|
+
if (type === SexpType.BcRepRef) {
|
|
1152
|
+
this.skipInteger();
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
else if (!BCLangTypes.has(type)) {
|
|
1156
|
+
this.skipItem();
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
if (type === SexpType.BcRepDef) {
|
|
1160
|
+
this.skipInteger();
|
|
1161
|
+
type = this.readInt();
|
|
1162
|
+
}
|
|
1163
|
+
if (type === SexpType.AltLangSxp || type === SexpType.AttrListSxp) {
|
|
1164
|
+
this.skipItem();
|
|
1543
1165
|
}
|
|
1166
|
+
this.readItem();
|
|
1167
|
+
this.skipItem();
|
|
1168
|
+
this.skipBCLang(this.readInt());
|
|
1169
|
+
this.skipBCLang(this.readInt());
|
|
1544
1170
|
}
|
|
1545
1171
|
/**
|
|
1546
1172
|
* Retrieves the `i`-th element of a generic list or vector. Throws Error if `x` is not a list type or `i` is out of bounds.
|
|
1547
1173
|
* See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L4122-L4142 | R source: VECTOR_ELT}
|
|
1548
1174
|
*/
|
|
1549
1175
|
VECTOR_ELT(x, i) {
|
|
1550
|
-
if (x.type
|
|
1551
|
-
x.type !== SexpType.ExprSxp &&
|
|
1552
|
-
x.type !== SexpType.WeakRefSxp) {
|
|
1176
|
+
if (!ListSexpTypes.has(x.type)) {
|
|
1553
1177
|
throw new Error(`VECTOR_ELT() can only be applied to a 'list', not a '${x.type}'`);
|
|
1554
1178
|
}
|
|
1555
1179
|
if (i < 0 || i >= x.value?.length) {
|
|
1556
1180
|
throw new Error('attempt access index %lld/%lld in VECTOR_ELT');
|
|
1557
1181
|
}
|
|
1558
|
-
|
|
1559
|
-
const ans = x.value[i];
|
|
1560
|
-
/* the element is marked as not mutable since complex
|
|
1561
|
-
assignment can't see reference counts on any intermediate
|
|
1562
|
-
containers in an ALTREP */
|
|
1563
|
-
// MARK_NOT_MUTABLE(ans);
|
|
1564
|
-
return ans;
|
|
1565
|
-
}
|
|
1566
|
-
else {
|
|
1567
|
-
return x.value[i];
|
|
1568
|
-
}
|
|
1182
|
+
return x.value[i];
|
|
1569
1183
|
}
|
|
1570
1184
|
/** Source-language expression for an unsupported bytecode object: its first constant pool entry, or {@link RValues.NilValue}. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L5566-L5574 | R source: bytecodeExpr} */
|
|
1571
1185
|
R_BytecodeExpr(s) {
|
|
@@ -1575,121 +1189,31 @@ class RDAParser {
|
|
|
1575
1189
|
return s.cdr.value?.length > 0 ? this.VECTOR_ELT(s.cdr, 0) : RValues.NilValue;
|
|
1576
1190
|
}
|
|
1577
1191
|
/**
|
|
1578
|
-
* Attempts to unserialize an ALTREP object.
|
|
1192
|
+
* Attempts to unserialize an ALTREP object. As flowR registers no ALTREP classes, an object of a supported vector
|
|
1193
|
+
* base type is read back as a length zero vector of that type. Throws error for any other base type.
|
|
1579
1194
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/altrep.c#L298-L338 | R source: ALTREP_UNSERIALIZE_EX}
|
|
1580
1195
|
*/
|
|
1581
1196
|
AltRepUnserializeEx(info, _state, _attr, _objf, _levs) {
|
|
1582
|
-
const cSym = info.car;
|
|
1583
|
-
const pSym = info.cdr.car;
|
|
1584
1197
|
const type = info.cdr.cdr.car.type;
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
switch (type) {
|
|
1588
|
-
case SexpType.LglSxp:
|
|
1589
|
-
case SexpType.IntSxp:
|
|
1590
|
-
case SexpType.RealSxp:
|
|
1591
|
-
case SexpType.CplxSxp:
|
|
1592
|
-
case SexpType.StrSxp:
|
|
1593
|
-
case SexpType.RawSxp:
|
|
1594
|
-
case SexpType.VecSxp:
|
|
1595
|
-
case SexpType.ExprSxp:
|
|
1596
|
-
rdaLog.warn(`cannot unserialize ALTVEC object of class '${cSym.name}'
|
|
1597
|
-
from package '${pSym.name}' returning length zero vector`);
|
|
1598
|
-
info.type = type;
|
|
1599
|
-
info.value = [];
|
|
1600
|
-
return info;
|
|
1601
|
-
default:
|
|
1602
|
-
throw new Error('cannot unserialize this ALTREP object');
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
return {};
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* The ALTREP class registered for `info`'s class/package symbol pair, `undefined` if unregistered, `null` if `info` is not a `ListSxp`.
|
|
1609
|
-
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/altrep.c#L279-L296 | R source: ALTREP_UNSERIALIZE_CLASS}
|
|
1610
|
-
*/
|
|
1611
|
-
ALTREP_UNSERIALIZE_CLASS(info) {
|
|
1612
|
-
if (info.type == SexpType.ListSxp) {
|
|
1613
|
-
const cSym = info.car;
|
|
1614
|
-
const pSym = info.cdr.car;
|
|
1615
|
-
let clss = this.LookupClass(cSym, pSym);
|
|
1616
|
-
if (clss === undefined) {
|
|
1617
|
-
const pName = this.ScalarString(pSym.name);
|
|
1618
|
-
try {
|
|
1619
|
-
this.R_FindNamespace(pName);
|
|
1620
|
-
}
|
|
1621
|
-
catch (e) {
|
|
1622
|
-
rdaLog.warn(`${pName.value} ${e}`);
|
|
1623
|
-
}
|
|
1624
|
-
clss = this.LookupClass(cSym, pSym);
|
|
1625
|
-
}
|
|
1626
|
-
return clss;
|
|
1627
|
-
}
|
|
1628
|
-
return null;
|
|
1629
|
-
}
|
|
1630
|
-
/** ALTREP class entry for `cSym`/`pSym`, `undefined` if not registered. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/altrep.c#L90-L94 | R source: LookupClass} */
|
|
1631
|
-
LookupClass(cSym, pSym) {
|
|
1632
|
-
const entry = this.LookupClassEntry(cSym, pSym);
|
|
1633
|
-
return entry === undefined || entry === null ? undefined : entry.car;
|
|
1634
|
-
}
|
|
1635
|
-
/** Searches the ALTREP class registry for an entry matching `cSym`/`pSym`. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/altrep.c#L53-L59 | R source: LookupClassEntry} */
|
|
1636
|
-
LookupClassEntry(cSym, pSym) {
|
|
1637
|
-
if (!this.Registry) {
|
|
1638
|
-
return null;
|
|
1639
|
-
}
|
|
1640
|
-
for (let chain = (this.Registry).cdr || null; chain; chain = chain.cdr) {
|
|
1641
|
-
if (chain.car.tag == cSym && chain.car.cdr.car === pSym) {
|
|
1642
|
-
return chain.car;
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
return null;
|
|
1646
|
-
}
|
|
1647
|
-
/** A length-1 {@link SexpType.StrSxp} character vector wrapping `x`. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/include/Rinlinedfuns.h#L1044-L1052 | R source: ScalarString} */
|
|
1648
|
-
ScalarString(x) {
|
|
1649
|
-
const ans = { type: SexpType.StrSxp, value: new Array(1) };
|
|
1650
|
-
this.SET_STRING_ELT(ans, 0, { name: x });
|
|
1651
|
-
return ans;
|
|
1652
|
-
}
|
|
1653
|
-
/** Recomputes and restores the cached hash-table priority count for environment `s`. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3685-L3698 | R source: R_RestoreHashCount} */
|
|
1654
|
-
restoreHashCount(s) {
|
|
1655
|
-
if (s.hashTab !== RValues.NilValue) {
|
|
1656
|
-
const table = s.hashTab;
|
|
1657
|
-
const size = table.value.length;
|
|
1658
|
-
let _count = 0;
|
|
1659
|
-
for (let i = 0; i < size; i++) {
|
|
1660
|
-
if (this.VECTOR_ELT(table, i) !== RValues.NilValue) {
|
|
1661
|
-
_count++;
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
// SET_HASHPRI(table, count);
|
|
1198
|
+
if (!AltVecSexpTypes.has(type)) {
|
|
1199
|
+
throw new Error('cannot unserialize this ALTREP object');
|
|
1665
1200
|
}
|
|
1201
|
+
rdaLog.warn(`cannot unserialize ALTVEC object of class '${info.car.name}' from package '${info.cdr.car.name}' returning length zero vector`);
|
|
1202
|
+
info.type = type;
|
|
1203
|
+
info.value = [];
|
|
1204
|
+
return info;
|
|
1666
1205
|
}
|
|
1667
1206
|
/** Converts a linked-list based R object tree into a flat array of top-level objects, omitting payloads when `shortcut`. */
|
|
1668
1207
|
flattenRObject(node, shortcut) {
|
|
1669
1208
|
const result = [];
|
|
1670
|
-
|
|
1671
|
-
if (!n || n === RValues.NilValue) {
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1209
|
+
for (let n = node; n && n !== RValues.NilValue; n = n.cdr) {
|
|
1674
1210
|
const name = n.tag?.name;
|
|
1211
|
+
const car = n.car;
|
|
1675
1212
|
if (name !== undefined) {
|
|
1676
|
-
result.push(shortcut ? {
|
|
1677
|
-
name: n.tag.
|
|
1678
|
-
type: n.car.type,
|
|
1679
|
-
} : {
|
|
1680
|
-
name: n.tag.name,
|
|
1681
|
-
value: n.car.value,
|
|
1682
|
-
hasAttribute: !!n.hasAttribute,
|
|
1683
|
-
attributes: n.attributes,
|
|
1684
|
-
type: n.car.type,
|
|
1685
|
-
tag: RValues.NilValue
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
if (n.cdr && n.cdr !== RValues.NilValue) {
|
|
1689
|
-
walk(n.cdr);
|
|
1213
|
+
result.push(shortcut ? { name, type: car.type }
|
|
1214
|
+
: { name, value: car.value, hasAttribute: !!n.hasAttribute, attributes: n.attributes, type: car.type, tag: RValues.NilValue });
|
|
1690
1215
|
}
|
|
1691
1216
|
}
|
|
1692
|
-
walk(node);
|
|
1693
1217
|
return result;
|
|
1694
1218
|
}
|
|
1695
1219
|
}
|