@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.
Files changed (977) hide show
  1. package/README.md +9 -9
  2. package/abstract-interpretation/absint-inference.d.ts +9 -25
  3. package/abstract-interpretation/absint-inference.js +7 -21
  4. package/abstract-interpretation/branch-paths-interpreter.js +1 -5
  5. package/abstract-interpretation/branch-paths.d.ts +1 -2
  6. package/abstract-interpretation/data-frame/arguments.d.ts +3 -14
  7. package/abstract-interpretation/data-frame/arguments.js +2 -10
  8. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -12
  9. package/abstract-interpretation/data-frame/dataframe-domain.js +6 -20
  10. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -6
  11. package/abstract-interpretation/data-frame/dataframe-semantics.js +161 -327
  12. package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -6
  13. package/abstract-interpretation/data-frame/semantics.d.ts +3 -0
  14. package/abstract-interpretation/data-frame/semantics.js +20 -42
  15. package/abstract-interpretation/data-frame/shape-inference.d.ts +5 -15
  16. package/abstract-interpretation/domains/abstract-domain.d.ts +7 -21
  17. package/abstract-interpretation/domains/abstract-domain.js +6 -18
  18. package/abstract-interpretation/domains/interval-domain.d.ts +2 -6
  19. package/abstract-interpretation/domains/interval-domain.js +3 -10
  20. package/abstract-interpretation/domains/lattice.d.ts +14 -42
  21. package/abstract-interpretation/domains/set-range-domain.d.ts +6 -18
  22. package/abstract-interpretation/domains/set-range-domain.js +4 -12
  23. package/abstract-interpretation/domains/state-domain.d.ts +9 -27
  24. package/abstract-interpretation/domains/value-abstract-domain.d.ts +22 -66
  25. package/abstract-interpretation/domains/value-abstract-domain.js +3 -9
  26. package/abstract-interpretation/unsupported-functions.d.ts +2 -6
  27. package/abstract-interpretation/unsupported-functions.js +3 -9
  28. package/abstract-interpretation/value-semantics.d.ts +1 -2
  29. package/benchmark/slicer.d.ts +4 -11
  30. package/benchmark/slicer.js +8 -24
  31. package/benchmark/stats/count-comments.d.ts +1 -3
  32. package/benchmark/stats/count-comments.js +1 -3
  33. package/benchmark/stats/print.d.ts +3 -10
  34. package/benchmark/stats/print.js +39 -110
  35. package/benchmark/stats/sigdb-counts.js +1 -5
  36. package/benchmark/stats/size-of.js +3 -13
  37. package/benchmark/stats/stats.d.ts +1 -3
  38. package/benchmark/stopwatch.d.ts +1 -3
  39. package/benchmark/stopwatch.js +1 -3
  40. package/benchmark/summarizer/first-phase/input.d.ts +2 -6
  41. package/benchmark/summarizer/first-phase/input.js +2 -6
  42. package/benchmark/summarizer/first-phase/process.d.ts +4 -12
  43. package/benchmark/summarizer/first-phase/process.js +22 -39
  44. package/benchmark/summarizer/second-phase/graph.d.ts +0 -1
  45. package/benchmark/summarizer/second-phase/graph.js +9 -33
  46. package/benchmark/summarizer/second-phase/process.d.ts +4 -12
  47. package/benchmark/summarizer/second-phase/process.js +78 -221
  48. package/benchmark/summarizer/summarizer.d.ts +4 -12
  49. package/cli/benchmark-app.js +1 -5
  50. package/cli/benchmark-helper-app.js +2 -10
  51. package/cli/common/options.d.ts +1 -3
  52. package/cli/common/options.js +1 -3
  53. package/cli/common/script.d.ts +1 -3
  54. package/cli/common/script.js +3 -11
  55. package/cli/common/scripts-info.d.ts +2 -7
  56. package/cli/common/scripts-info.js +2 -6
  57. package/cli/flowr-main-options.d.ts +1 -3
  58. package/cli/flowr-main-options.js +6 -31
  59. package/cli/flowr.js +5 -8
  60. package/cli/repl/commands/repl-commands.d.ts +5 -15
  61. package/cli/repl/commands/repl-commands.js +7 -17
  62. package/cli/repl/commands/repl-dataflow.js +4 -4
  63. package/cli/repl/commands/repl-execute.d.ts +1 -4
  64. package/cli/repl/commands/repl-execute.js +1 -4
  65. package/cli/repl/commands/repl-main.d.ts +4 -14
  66. package/cli/repl/commands/repl-main.js +1 -5
  67. package/cli/repl/commands/repl-query.js +2 -10
  68. package/cli/repl/commands/repl-signature.js +2 -3
  69. package/cli/repl/completion.d.ts +11 -3
  70. package/cli/repl/completion.js +32 -0
  71. package/cli/repl/core.d.ts +5 -16
  72. package/cli/repl/core.js +7 -19
  73. package/cli/repl/execute.js +3 -11
  74. package/cli/repl/ghost-hint.js +6 -6
  75. package/cli/repl/parser/slice-query-parser.d.ts +3 -9
  76. package/cli/repl/parser/slice-query-parser.js +6 -10
  77. package/cli/repl/print-version.d.ts +2 -6
  78. package/cli/repl/print-version.js +4 -8
  79. package/cli/repl/prompt.d.ts +1 -0
  80. package/cli/repl/prompt.js +1 -0
  81. package/cli/repl/server/connection.d.ts +2 -6
  82. package/cli/repl/server/connection.js +8 -35
  83. package/cli/repl/server/messages/all-messages.d.ts +3 -9
  84. package/cli/repl/server/messages/all-messages.js +1 -4
  85. package/cli/repl/server/messages/message-analysis.d.ts +6 -18
  86. package/cli/repl/server/messages/message-error.d.ts +1 -3
  87. package/cli/repl/server/messages/message-hello.d.ts +2 -7
  88. package/cli/repl/server/messages/message-repl.d.ts +1 -1
  89. package/cli/repl/server/messages/message-slice.d.ts +2 -7
  90. package/cli/repl/server/net.d.ts +3 -11
  91. package/cli/repl/server/net.js +1 -3
  92. package/cli/repl/server/send.d.ts +2 -6
  93. package/cli/repl/server/send.js +2 -6
  94. package/cli/repl/server/server.js +1 -6
  95. package/cli/repl/server/validate.d.ts +3 -9
  96. package/cli/repl/server/validate.js +3 -9
  97. package/cli/script-core/summarizer-core.d.ts +1 -3
  98. package/cli/script-core/summarizer-core.js +1 -3
  99. package/cli/summarizer-app.js +1 -4
  100. package/cli/wiki.d.ts +1 -3
  101. package/cli/wiki.js +3 -15
  102. package/clones/algorithms/baxter-ast.js +2 -2
  103. package/clones/clone-ast.js +2 -2
  104. package/clones/clone-detector.js +2 -2
  105. package/config.d.ts +5 -15
  106. package/config.js +17 -59
  107. package/control-flow/basic-cfg-guided-visitor.d.ts +2 -6
  108. package/control-flow/basic-cfg-guided-visitor.js +2 -6
  109. package/control-flow/cfg-dead-code.d.ts +1 -1
  110. package/control-flow/cfg-dead-code.js +16 -41
  111. package/control-flow/cfg-properties.d.ts +1 -3
  112. package/control-flow/cfg-properties.js +1 -3
  113. package/control-flow/cfg-simplification.d.ts +2 -6
  114. package/control-flow/cfg-simplification.js +2 -6
  115. package/control-flow/cfg-to-basic-blocks.d.ts +1 -3
  116. package/control-flow/cfg-to-basic-blocks.js +2 -9
  117. package/control-flow/control-flow-graph.d.ts +16 -49
  118. package/control-flow/control-flow-graph.js +60 -194
  119. package/control-flow/dfg-cfg-guided-visitor.d.ts +2 -6
  120. package/control-flow/dfg-cfg-guided-visitor.js +2 -6
  121. package/control-flow/happens-before.d.ts +1 -3
  122. package/control-flow/happens-before.js +1 -3
  123. package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -7
  124. package/control-flow/semantic-cfg-guided-visitor.js +12 -45
  125. package/control-flow/simple-visitor.d.ts +1 -5
  126. package/control-flow/simple-visitor.js +1 -5
  127. package/control-flow/syntax-cfg-guided-visitor.d.ts +23 -67
  128. package/control-flow/syntax-cfg-guided-visitor.js +22 -66
  129. package/control-flow/useless-loop.d.ts +0 -5
  130. package/control-flow/useless-loop.js +0 -5
  131. package/core/pipeline-executor.d.ts +1 -4
  132. package/core/pipeline-executor.js +2 -8
  133. package/core/print/print.d.ts +4 -14
  134. package/core/print/slice-diff-ansi.d.ts +1 -3
  135. package/core/print/slice-diff-ansi.js +2 -7
  136. package/core/steps/all/core/01-parse-tree-sitter.js +1 -4
  137. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  138. package/core/steps/all/static-slicing/00-slice.d.ts +1 -1
  139. package/core/steps/all/static-slicing/00-slice.js +1 -3
  140. package/core/steps/all/static-slicing/10-reconstruct.js +1 -3
  141. package/core/steps/pipeline/create-pipeline.d.ts +1 -3
  142. package/core/steps/pipeline/create-pipeline.js +2 -8
  143. package/core/steps/pipeline/default-pipelines.d.ts +48 -323
  144. package/core/steps/pipeline/default-pipelines.js +9 -47
  145. package/core/steps/pipeline/invalid-pipeline-error.d.ts +1 -3
  146. package/core/steps/pipeline/invalid-pipeline-error.js +1 -3
  147. package/core/steps/pipeline/pipeline.d.ts +1 -6
  148. package/core/steps/pipeline-step.d.ts +2 -6
  149. package/data/packed.js +2 -2
  150. package/dataflow/cluster.d.ts +1 -3
  151. package/dataflow/cluster.js +1 -3
  152. package/dataflow/environments/ambient-contract.d.ts +102 -0
  153. package/dataflow/environments/ambient-contract.js +134 -0
  154. package/dataflow/environments/ambient-effect.d.ts +72 -8
  155. package/dataflow/environments/ambient-effect.js +59 -17
  156. package/dataflow/environments/ambient-state-name.d.ts +5 -1
  157. package/dataflow/environments/ambient-state-name.js +8 -5
  158. package/dataflow/environments/append.d.ts +1 -3
  159. package/dataflow/environments/append.js +2 -7
  160. package/dataflow/environments/apply-kill.d.ts +2 -3
  161. package/dataflow/environments/apply-kill.js +24 -49
  162. package/dataflow/environments/built-in-config.d.ts +1 -2
  163. package/dataflow/environments/built-in-proc-name.d.ts +2 -6
  164. package/dataflow/environments/built-in-proc-name.js +2 -6
  165. package/dataflow/environments/built-in-props.js +1 -4
  166. package/dataflow/environments/built-in.d.ts +2 -3
  167. package/dataflow/environments/built-in.js +3 -6
  168. package/dataflow/environments/clone.js +1 -4
  169. package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
  170. package/dataflow/environments/default-builtin-config/base-functions.js +4 -4
  171. package/dataflow/environments/default-builtin-config/define-helpers.d.ts +4 -0
  172. package/dataflow/environments/default-builtin-config/define-helpers.js +4 -0
  173. package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +1 -1
  174. package/dataflow/environments/default-builtin-config/dev-tooling.js +10 -7
  175. package/dataflow/environments/default-builtin-config/graphics-devices.js +1 -1
  176. package/dataflow/environments/default-builtin-config/guard-builders.d.ts +7 -0
  177. package/dataflow/environments/default-builtin-config/guard-builders.js +7 -0
  178. package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +2 -2
  179. package/dataflow/environments/default-builtin-config/guards.js +2 -7
  180. package/dataflow/environments/default-builtin-config/index.d.ts +2 -2
  181. package/dataflow/environments/default-builtin-config/package-data-table.d.ts +1 -1
  182. package/dataflow/environments/default-builtin-config/package-data-table.js +2 -3
  183. package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
  184. package/dataflow/environments/default-builtin-config/package-utils.js +18 -4
  185. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +71 -0
  186. package/dataflow/environments/default-builtin-config/shared-configs.js +19 -4
  187. package/dataflow/environments/define.js +1 -4
  188. package/dataflow/environments/diff.d.ts +4 -10
  189. package/dataflow/environments/diff.js +3 -9
  190. package/dataflow/environments/environment.d.ts +2 -4
  191. package/dataflow/environments/environment.js +9 -18
  192. package/dataflow/environments/frame-memory.d.ts +0 -1
  193. package/dataflow/environments/frame-memory.js +0 -1
  194. package/dataflow/environments/overwrite.js +1 -4
  195. package/dataflow/environments/query-fn-props.d.ts +9 -3
  196. package/dataflow/environments/query-fn-props.js +37 -63
  197. package/dataflow/environments/reference-to-maybe.d.ts +3 -6
  198. package/dataflow/environments/reference-to-maybe.js +1 -3
  199. package/dataflow/environments/resolve-helper.d.ts +3 -2
  200. package/dataflow/environments/resolve-helper.js +2 -0
  201. package/dataflow/environments/scoping.js +2 -8
  202. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -0
  203. package/dataflow/eval/resolve/alias-tracking.js +52 -80
  204. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -3
  205. package/dataflow/eval/resolve/resolve-argument.js +8 -13
  206. package/dataflow/eval/resolve/resolve-get.js +1 -4
  207. package/dataflow/eval/resolve/resolve-strings.js +3 -3
  208. package/dataflow/eval/resolve/resolve-working-directory.js +1 -3
  209. package/dataflow/eval/resolve/resolve.d.ts +1 -1
  210. package/dataflow/eval/resolve/resolve.js +15 -16
  211. package/dataflow/eval/values/general.js +10 -11
  212. package/dataflow/eval/values/intervals/interval-constants.d.ts +0 -2
  213. package/dataflow/eval/values/intervals/interval-constants.js +1 -9
  214. package/dataflow/eval/values/logical/logical-constants.js +1 -4
  215. package/dataflow/eval/values/scalar/scalar-constants.d.ts +2 -6
  216. package/dataflow/eval/values/scalar/scalar-constants.js +4 -18
  217. package/dataflow/eval/values/sets/set-constants.js +1 -4
  218. package/dataflow/eval/values/vectors/vector-constants.js +1 -5
  219. package/dataflow/extractor.js +103 -16
  220. package/dataflow/fn/argument-roles.d.ts +2 -2
  221. package/dataflow/fn/argument-roles.js +9 -5
  222. package/dataflow/fn/call-sites.d.ts +57 -0
  223. package/dataflow/fn/call-sites.js +167 -0
  224. package/dataflow/fn/class-declaration.js +2 -2
  225. package/dataflow/fn/dispatch.js +6 -5
  226. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  227. package/dataflow/fn/frame-reflection.d.ts +3 -3
  228. package/dataflow/fn/function-props.d.ts +1 -1
  229. package/dataflow/fn/function-props.js +1 -4
  230. package/dataflow/fn/function-semantics.d.ts +14 -1
  231. package/dataflow/fn/function-semantics.js +3 -0
  232. package/dataflow/fn/guards/built-in-guards.d.ts +2 -2
  233. package/dataflow/fn/guards/built-in-guards.js +5 -11
  234. package/dataflow/fn/guards/call-contracts.js +1 -1
  235. package/dataflow/fn/guards/function-guards.d.ts +3 -3
  236. package/dataflow/fn/guards/function-guards.js +17 -15
  237. package/dataflow/fn/guards/guard-claims.js +15 -14
  238. package/dataflow/fn/guards/guard-knowledge.d.ts +1 -1
  239. package/dataflow/fn/guards/guard-term.js +2 -2
  240. package/dataflow/fn/guards/stated-guards.js +1 -1
  241. package/dataflow/fn/guards/stored-location.d.ts +21 -0
  242. package/dataflow/fn/guards/stored-location.js +21 -0
  243. package/dataflow/fn/strict-function.d.ts +1 -1
  244. package/dataflow/fn/strict-function.js +7 -9
  245. package/dataflow/graph/call-graph.d.ts +1 -1
  246. package/dataflow/graph/call-graph.js +1 -5
  247. package/dataflow/graph/dataflowgraph-builder.d.ts +3 -2
  248. package/dataflow/graph/dataflowgraph-builder.js +22 -29
  249. package/dataflow/graph/df-helper.js +18 -31
  250. package/dataflow/graph/edge.d.ts +3 -9
  251. package/dataflow/graph/edge.js +2 -6
  252. package/dataflow/graph/graph-helper.d.ts +2 -3
  253. package/dataflow/graph/graph.d.ts +1 -2
  254. package/dataflow/graph/graph.js +8 -13
  255. package/dataflow/graph/match-args.d.ts +1 -1
  256. package/dataflow/graph/match-args.js +13 -31
  257. package/dataflow/graph/quads.js +2 -7
  258. package/dataflow/graph/vertex.d.ts +1 -1
  259. package/dataflow/graph/vertex.js +1 -5
  260. package/dataflow/hooks.d.ts +1 -1
  261. package/dataflow/info.d.ts +8 -25
  262. package/dataflow/info.js +9 -32
  263. package/dataflow/internal/control-flow.d.ts +1 -2
  264. package/dataflow/internal/linker.d.ts +2 -3
  265. package/dataflow/internal/linker.js +38 -39
  266. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +3 -8
  267. package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -10
  268. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  269. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -12
  270. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +10 -4
  271. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +31 -4
  272. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -3
  273. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +54 -63
  274. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -4
  275. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +12 -16
  276. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +9 -11
  277. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  278. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -6
  279. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -3
  280. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +4 -3
  281. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
  282. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +1 -7
  283. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +2 -3
  284. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +17 -40
  285. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -2
  286. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +6 -16
  287. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +3 -3
  288. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +23 -27
  289. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -8
  290. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  291. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -14
  292. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -7
  293. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -6
  294. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +10 -34
  295. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  296. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
  297. package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +2 -2
  298. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +29 -128
  299. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
  300. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +4 -11
  301. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +1 -1
  302. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -6
  303. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +7 -17
  304. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -9
  305. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  306. package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +1 -4
  307. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -11
  308. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +4 -11
  309. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -11
  310. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +0 -1
  311. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +0 -1
  312. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  313. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -11
  314. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
  315. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  316. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -3
  317. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +1 -3
  318. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -4
  319. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -4
  320. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  321. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -9
  322. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -1
  323. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +1 -6
  324. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  325. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +1 -1
  326. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +2 -2
  327. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +5 -23
  328. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  329. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  330. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
  331. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +14 -14
  332. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -1
  333. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  334. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
  335. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
  336. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +17 -28
  337. package/dataflow/internal/process/functions/call/common.d.ts +2 -2
  338. package/dataflow/internal/process/functions/call/common.js +4 -5
  339. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  340. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -3
  341. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -2
  342. package/dataflow/internal/process/functions/call/nse-kind.d.ts +1 -4
  343. package/dataflow/internal/process/functions/call/nse-kind.js +1 -4
  344. package/dataflow/internal/process/functions/call/nse.js +1 -6
  345. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -2
  346. package/dataflow/internal/process/functions/call/quoted.js +1 -1
  347. package/dataflow/internal/process/functions/process-argument.d.ts +2 -6
  348. package/dataflow/internal/process/functions/process-argument.js +3 -11
  349. package/dataflow/internal/process/functions/process-parameter.d.ts +0 -1
  350. package/dataflow/internal/process/functions/process-parameter.js +0 -1
  351. package/dataflow/internal/process/process-named-call.d.ts +1 -3
  352. package/dataflow/internal/process/process-named-call.js +1 -3
  353. package/dataflow/internal/process/process-value.d.ts +1 -4
  354. package/dataflow/internal/process/process-value.js +2 -9
  355. package/dataflow/origin/dfg-get-origin.d.ts +1 -3
  356. package/dataflow/origin/dfg-get-origin.js +10 -30
  357. package/dataflow/origin/dfg-get-symbol-refs.d.ts +0 -1
  358. package/dataflow/origin/dfg-get-symbol-refs.js +0 -1
  359. package/dataflow/processor.d.ts +8 -24
  360. package/dataflow/processor.js +1 -0
  361. package/documentation/data/dfg/doc-ambient.js +12 -3
  362. package/documentation/data/dfg/doc-data-dfg-util.d.ts +2 -6
  363. package/documentation/data/dfg/doc-data-dfg-util.js +2 -6
  364. package/documentation/data/faq/faqs.js +1 -3
  365. package/documentation/data/faq/recommended-configs.js +2 -15
  366. package/documentation/data/faq/wiki-faq-store.d.ts +1 -3
  367. package/documentation/data/faq/wiki-faq-store.js +4 -13
  368. package/documentation/data/interface/doc-writing-code.d.ts +1 -3
  369. package/documentation/data/interface/doc-writing-code.js +4 -12
  370. package/documentation/data/server/doc-data-server-messages.js +28 -120
  371. package/documentation/doc-capabilities.js +2 -2
  372. package/documentation/doc-readme.d.ts +2 -5
  373. package/documentation/doc-readme.js +4 -18
  374. package/documentation/doc-util/doc-benchmarks.d.ts +2 -6
  375. package/documentation/doc-util/doc-benchmarks.js +2 -6
  376. package/documentation/doc-util/doc-cfg.d.ts +4 -10
  377. package/documentation/doc-util/doc-cfg.js +7 -21
  378. package/documentation/doc-util/doc-cli-option.d.ts +4 -10
  379. package/documentation/doc-util/doc-cli-option.js +3 -9
  380. package/documentation/doc-util/doc-dfg.d.ts +10 -9
  381. package/documentation/doc-util/doc-dfg.js +9 -24
  382. package/documentation/doc-util/doc-escape.js +1 -7
  383. package/documentation/doc-util/doc-files.d.ts +2 -6
  384. package/documentation/doc-util/doc-files.js +2 -6
  385. package/documentation/doc-util/doc-general.d.ts +0 -10
  386. package/documentation/doc-util/doc-general.js +0 -18
  387. package/documentation/doc-util/doc-normalized-ast.js +4 -7
  388. package/documentation/doc-util/doc-playground.d.ts +1 -1
  389. package/documentation/doc-util/doc-query.d.ts +6 -8
  390. package/documentation/doc-util/doc-query.js +9 -12
  391. package/documentation/doc-util/doc-repl.d.ts +1 -3
  392. package/documentation/doc-util/doc-repl.js +1 -3
  393. package/documentation/doc-util/doc-search.d.ts +1 -3
  394. package/documentation/doc-util/doc-search.js +2 -7
  395. package/documentation/doc-util/doc-server-message.d.ts +4 -12
  396. package/documentation/doc-util/doc-server-message.js +4 -12
  397. package/documentation/doc-util/doc-structure.d.ts +5 -7
  398. package/documentation/doc-util/doc-structure.js +9 -9
  399. package/documentation/doc-util/doc-types.d.ts +4 -12
  400. package/documentation/doc-util/doc-types.js +29 -127
  401. package/documentation/issue-linting-rule.d.ts +2 -5
  402. package/documentation/issue-linting-rule.js +1 -3
  403. package/documentation/wiki-absint.js +3 -6
  404. package/documentation/wiki-analyzer.d.ts +2 -5
  405. package/documentation/wiki-analyzer.js +22 -61
  406. package/documentation/wiki-cfg.d.ts +1 -2
  407. package/documentation/wiki-cfg.js +23 -56
  408. package/documentation/wiki-core.d.ts +3 -8
  409. package/documentation/wiki-core.js +32 -59
  410. package/documentation/wiki-create-linting-rules.d.ts +1 -2
  411. package/documentation/wiki-create-linting-rules.js +1 -4
  412. package/documentation/wiki-dataflow-graph.d.ts +2 -5
  413. package/documentation/wiki-dataflow-graph.js +73 -129
  414. package/documentation/wiki-engine.d.ts +2 -5
  415. package/documentation/wiki-engine.js +3 -11
  416. package/documentation/wiki-faq.d.ts +2 -5
  417. package/documentation/wiki-faq.js +1 -3
  418. package/documentation/wiki-helper-objects.d.ts +2 -5
  419. package/documentation/wiki-helper-objects.js +3 -5
  420. package/documentation/wiki-interface.d.ts +2 -5
  421. package/documentation/wiki-interface.js +14 -54
  422. package/documentation/wiki-linter.d.ts +2 -8
  423. package/documentation/wiki-linter.js +23 -94
  424. package/documentation/wiki-linting-and-testing.d.ts +2 -5
  425. package/documentation/wiki-linting-and-testing.js +4 -9
  426. package/documentation/wiki-mk/doc-context.d.ts +6 -14
  427. package/documentation/wiki-mk/doc-context.js +8 -28
  428. package/documentation/wiki-mk/doc-maker.d.ts +9 -27
  429. package/documentation/wiki-mk/doc-maker.js +6 -18
  430. package/documentation/wiki-normalized-ast.d.ts +2 -5
  431. package/documentation/wiki-normalized-ast.js +2 -7
  432. package/documentation/wiki-onboarding.d.ts +2 -5
  433. package/documentation/wiki-onboarding.js +1 -3
  434. package/documentation/wiki-overview.d.ts +2 -5
  435. package/documentation/wiki-overview.js +1 -3
  436. package/documentation/wiki-query.d.ts +2 -5
  437. package/documentation/wiki-query.js +165 -343
  438. package/documentation/wiki-search.d.ts +2 -5
  439. package/documentation/wiki-search.js +1 -3
  440. package/documentation/wiki-setup.d.ts +2 -5
  441. package/documentation/wiki-setup.js +1 -3
  442. package/documentation/wiki-signature-database.d.ts +2 -5
  443. package/documentation/wiki-signature-database.js +3 -5
  444. package/engines.d.ts +1 -4
  445. package/engines.js +1 -4
  446. package/linter/linter-executor.d.ts +1 -3
  447. package/linter/linter-executor.js +3 -11
  448. package/linter/linter-fix.d.ts +5 -0
  449. package/linter/linter-fix.js +7 -22
  450. package/linter/linter-format.d.ts +23 -55
  451. package/linter/linter-format.js +13 -26
  452. package/linter/linter-rules.d.ts +87 -74
  453. package/linter/linter-rules.js +20 -8
  454. package/linter/linter-tags.d.ts +9 -29
  455. package/linter/linter-tags.js +9 -29
  456. package/linter/rules/{absolute-path.d.ts → absolute-file-paths.d.ts} +10 -10
  457. package/linter/rules/{absolute-path.js → absolute-file-paths.js} +16 -20
  458. package/linter/rules/cmd-check/call-arguments.js +2 -11
  459. package/linter/rules/cmd-check/class-string-comparison.js +1 -4
  460. package/linter/rules/cmd-check/cmd-check-util.d.ts +3 -0
  461. package/linter/rules/cmd-check/cmd-check-util.js +17 -7
  462. package/linter/rules/cmd-check/compiled-code.js +6 -6
  463. package/linter/rules/cmd-check/dependency-declaration.js +4 -10
  464. package/linter/rules/cmd-check/description-metadata.js +5 -9
  465. package/linter/rules/cmd-check/documentation-mismatch.d.ts +9 -2
  466. package/linter/rules/cmd-check/documentation-mismatch.js +11 -69
  467. package/linter/rules/cmd-check/file-checks.d.ts +5 -0
  468. package/linter/rules/cmd-check/file-checks.js +5 -3
  469. package/linter/rules/cmd-check/foreign-function-calls.js +5 -7
  470. package/linter/rules/cmd-check/global-environment-modification.js +6 -9
  471. package/linter/rules/cmd-check/namespace-tampering.js +14 -24
  472. package/linter/rules/cmd-check/non-ascii-code.js +1 -4
  473. package/linter/rules/cmd-check/package-data.js +4 -4
  474. package/linter/rules/cmd-check/package-files.d.ts +1 -3
  475. package/linter/rules/cmd-check/package-files.js +2 -2
  476. package/linter/rules/cmd-check/package-hooks.js +1 -4
  477. package/linter/rules/cmd-check/package-metafiles.d.ts +2 -2
  478. package/linter/rules/cmd-check/package-metafiles.js +5 -23
  479. package/linter/rules/cmd-check/package-runtime.js +6 -19
  480. package/linter/rules/cmd-check/package-structure.js +7 -8
  481. package/linter/rules/cmd-check/rd-files.d.ts +2 -2
  482. package/linter/rules/cmd-check/rd-files.js +31 -37
  483. package/linter/rules/cmd-check/s-three-method-consistency.js +8 -13
  484. package/linter/rules/cmd-check/true-false-abbreviation.js +1 -3
  485. package/linter/rules/dataframe-access-validation.d.ts +9 -9
  486. package/linter/rules/dataframe-access-validation.js +2 -2
  487. package/linter/rules/dead-code.js +2 -15
  488. package/linter/rules/deprecated-functions.d.ts +2 -4
  489. package/linter/rules/deprecated-functions.js +45 -141
  490. package/linter/rules/file-path-validity.d.ts +1 -3
  491. package/linter/rules/file-path-validity.js +20 -61
  492. package/linter/rules/function-finder-util.d.ts +4 -9
  493. package/linter/rules/function-finder-util.js +5 -16
  494. package/linter/rules/interactive-functions.js +1 -3
  495. package/linter/rules/naming-convention.d.ts +5 -15
  496. package/linter/rules/naming-convention.js +14 -54
  497. package/linter/rules/network-functions.d.ts +3 -7
  498. package/linter/rules/network-functions.js +1 -3
  499. package/linter/rules/overwritten-file.js +4 -4
  500. package/linter/rules/problematic-inputs.d.ts +1 -2
  501. package/linter/rules/problematic-inputs.js +1 -4
  502. package/linter/rules/process-state-in-session.d.ts +0 -1
  503. package/linter/rules/process-state-in-session.js +6 -6
  504. package/linter/rules/roxygen-arguments.d.ts +6 -6
  505. package/linter/rules/roxygen-arguments.js +2 -2
  506. package/linter/rules/seeded-randomness.d.ts +2 -4
  507. package/linter/rules/seeded-randomness.js +9 -9
  508. package/linter/rules/software-has-license.js +1 -3
  509. package/linter/rules/software-has-tests.js +2 -10
  510. package/linter/rules/{stop-with-call-arg.d.ts → stop-call.d.ts} +6 -6
  511. package/linter/rules/{stop-with-call-arg.js → stop-call.js} +4 -6
  512. package/linter/rules/syntactically-valid.js +17 -44
  513. package/linter/rules/unclosed-connection.d.ts +1 -2
  514. package/linter/rules/unclosed-connection.js +1 -4
  515. package/linter/rules/undefined-symbol.js +24 -60
  516. package/linter/rules/unescaped-arguments.d.ts +10 -30
  517. package/linter/rules/unescaped-arguments.js +20 -53
  518. package/linter/rules/{unused-definition.d.ts → unused-definitions.d.ts} +12 -14
  519. package/linter/rules/{unused-definition.js → unused-definitions.js} +41 -84
  520. package/linter/rules/unused-import.d.ts +1 -1
  521. package/linter/rules/unused-import.js +4 -13
  522. package/linter/rules/useless-loop.js +3 -13
  523. package/package.json +1 -1
  524. package/project/cache/flowr-analyzer-cache.d.ts +2 -7
  525. package/project/cache/flowr-analyzer-cache.js +5 -14
  526. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +2 -3
  527. package/project/cache/flowr-analyzer-controlflow-cache.js +0 -1
  528. package/project/cache/flowr-cache.d.ts +2 -7
  529. package/project/cache/flowr-cache.js +2 -7
  530. package/project/context/abstract-flowr-analyzer-context.d.ts +7 -22
  531. package/project/context/abstract-flowr-analyzer-context.js +5 -16
  532. package/project/context/flowr-analyzer-context.d.ts +7 -12
  533. package/project/context/flowr-analyzer-context.js +8 -22
  534. package/project/context/flowr-analyzer-dependencies-context.d.ts +7 -19
  535. package/project/context/flowr-analyzer-dependencies-context.js +6 -21
  536. package/project/context/flowr-analyzer-environment-context.d.ts +12 -30
  537. package/project/context/flowr-analyzer-environment-context.js +4 -15
  538. package/project/context/flowr-analyzer-files-context.d.ts +14 -37
  539. package/project/context/flowr-analyzer-files-context.js +27 -87
  540. package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
  541. package/project/context/flowr-analyzer-gas-context.js +9 -31
  542. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -10
  543. package/project/context/flowr-analyzer-incremental-analysis-context.js +2 -6
  544. package/project/context/flowr-analyzer-loading-order-context.d.ts +5 -15
  545. package/project/context/flowr-analyzer-meta-context.d.ts +8 -33
  546. package/project/context/flowr-analyzer-meta-context.js +0 -1
  547. package/project/context/flowr-file.d.ts +6 -14
  548. package/project/context/flowr-file.js +1 -3
  549. package/project/dependency-version-space.d.ts +1 -3
  550. package/project/dependency-version-space.js +41 -135
  551. package/project/flowr-analyzer-builder.d.ts +7 -5
  552. package/project/flowr-analyzer-builder.js +10 -12
  553. package/project/flowr-analyzer.d.ts +12 -34
  554. package/project/flowr-analyzer.js +5 -14
  555. package/project/incremental/incremental-parse/edit-computation.js +1 -8
  556. package/project/incremental/incremental-parse/incremental-parse.js +3 -12
  557. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +13 -35
  558. package/project/plugins/file-plugins/files/flowr-description-file.js +12 -38
  559. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -2
  560. package/project/plugins/file-plugins/files/flowr-manifest-files.js +1 -4
  561. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -2
  562. package/project/plugins/file-plugins/files/flowr-namespace-file.js +8 -42
  563. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -7
  564. package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +1 -2
  565. package/project/plugins/file-plugins/files/flowr-rd-file.js +17 -32
  566. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +15 -40
  567. package/project/plugins/file-plugins/files/flowr-rda-file.js +343 -819
  568. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +6 -18
  569. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -34
  570. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +1 -2
  571. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +4 -13
  572. package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -18
  573. package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +1 -1
  574. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -3
  575. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -3
  576. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -5
  577. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +2 -6
  578. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +2 -6
  579. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +1 -4
  580. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -4
  581. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -3
  582. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -3
  583. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +1 -3
  584. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +1 -3
  585. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +1 -3
  586. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +1 -3
  587. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -3
  588. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -3
  589. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -3
  590. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -3
  591. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +1 -3
  592. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -3
  593. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -3
  594. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -3
  595. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +1 -3
  596. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +1 -3
  597. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -3
  598. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +1 -3
  599. package/project/plugins/flowr-analyzer-plugin.d.ts +2 -6
  600. package/project/plugins/flowr-analyzer-plugin.js +2 -6
  601. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -3
  602. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +1 -3
  603. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +1 -5
  604. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -4
  605. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +2 -2
  606. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +13 -9
  607. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -3
  608. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +0 -5
  609. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +7 -35
  610. package/project/plugins/package-version-plugins/package.d.ts +1 -1
  611. package/project/plugins/plugin-registry.d.ts +3 -10
  612. package/project/plugins/plugin-registry.js +3 -10
  613. package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +1 -1
  614. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -8
  615. package/project/sigdb/build.d.ts +2 -0
  616. package/project/sigdb/build.js +119 -185
  617. package/project/sigdb/decode.d.ts +1 -1
  618. package/project/sigdb/decode.js +3 -4
  619. package/project/sigdb/guarded-source.js +2 -2
  620. package/project/sigdb/manifest.js +10 -10
  621. package/project/sigdb/memory-source.d.ts +1 -1
  622. package/project/sigdb/memory-source.js +1 -1
  623. package/project/sigdb/on-demand/package-sources.js +2 -2
  624. package/project/sigdb/on-demand/recoverer.d.ts +1 -1
  625. package/project/sigdb/on-demand/remote-sources.js +2 -2
  626. package/project/sigdb/reader.d.ts +36 -25
  627. package/project/sigdb/reader.js +63 -81
  628. package/project/sigdb/sigdb-download.js +2 -12
  629. package/project/sigdb/signature-db.d.ts +1 -1
  630. package/project/sigdb/signature-db.js +6 -6
  631. package/project/sigdb/spec-query.js +4 -4
  632. package/queries/base-query-format.js +2 -8
  633. package/queries/catalog/absint-query/absint-query-format.d.ts +1 -3
  634. package/queries/catalog/absint-query/absint-query-format.js +4 -19
  635. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +2 -4
  636. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +2 -4
  637. package/queries/catalog/call-context-query/call-context-query-executor.js +7 -45
  638. package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -21
  639. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +5 -11
  640. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -10
  641. package/queries/catalog/call-context-query/identify-link-to-relation.d.ts +1 -4
  642. package/queries/catalog/call-context-query/identify-link-to-relation.js +1 -4
  643. package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +1 -3
  644. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -7
  645. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -3
  646. package/queries/catalog/cluster-query/cluster-query-format.d.ts +3 -7
  647. package/queries/catalog/cluster-query/cluster-query-format.js +5 -13
  648. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +2 -4
  649. package/queries/catalog/code-clones-query/code-clones-query-format.js +5 -18
  650. package/queries/catalog/config-query/config-query-format.d.ts +1 -3
  651. package/queries/catalog/config-query/config-query-format.js +1 -3
  652. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +3 -10
  653. package/queries/catalog/control-flow-query/control-flow-query-format.js +5 -13
  654. package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +2 -4
  655. package/queries/catalog/data-columns-query/data-columns-query-format.js +5 -10
  656. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +2 -6
  657. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +3 -11
  658. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -6
  659. package/queries/catalog/dataflow-query/dataflow-query-format.js +3 -11
  660. package/queries/catalog/dependencies-query/data-flow.js +5 -4
  661. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -3
  662. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -15
  663. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -3
  664. package/queries/catalog/dependencies-query/dependencies-query-format.js +10 -34
  665. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +1 -1
  666. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +0 -1
  667. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +6 -5
  668. package/queries/catalog/dependencies-query/function-info/remote-functions.js +24 -17
  669. package/queries/catalog/dependencies-query/function-info/tagged-functions.js +1 -4
  670. package/queries/catalog/dependencies-query/function-info/test-functions.js +2 -8
  671. package/queries/catalog/dependencies-query/function-info/transform-functions.js +1 -4
  672. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +1 -3
  673. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -3
  674. package/queries/catalog/dependencies-query/plot-description.js +2 -2
  675. package/queries/catalog/dice-query/dice-query-format.js +2 -8
  676. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -3
  677. package/queries/catalog/does-call-query/does-call-query-format.js +8 -35
  678. package/queries/catalog/files-query/files-query-format.d.ts +3 -7
  679. package/queries/catalog/files-query/files-query-format.js +8 -46
  680. package/queries/catalog/function-info-query/function-info-query-executor.js +1 -7
  681. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -3
  682. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -3
  683. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -4
  684. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -3
  685. package/queries/catalog/id-map-query/id-map-query-format.js +3 -11
  686. package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
  687. package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +1 -3
  688. package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -7
  689. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -4
  690. package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -2
  691. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +5 -11
  692. package/queries/catalog/input-sources-query/simple-input-classifier.js +2 -1
  693. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -7
  694. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +7 -10
  695. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +2 -2
  696. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +4 -6
  697. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +2 -2
  698. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +4 -7
  699. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -7
  700. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -3
  701. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -7
  702. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -3
  703. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -4
  704. package/queries/catalog/linter-query/linter-query-format.js +4 -26
  705. package/queries/catalog/location-map-query/location-map-query-format.js +4 -20
  706. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +2 -6
  707. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +3 -11
  708. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -3
  709. package/queries/catalog/origin-query/origin-query-format.js +3 -14
  710. package/queries/catalog/project-query/project-query-format.d.ts +3 -5
  711. package/queries/catalog/project-query/project-query-format.js +2 -7
  712. package/queries/catalog/provenance-query/provenance-query-format.d.ts +4 -10
  713. package/queries/catalog/provenance-query/provenance-query-format.js +3 -10
  714. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -7
  715. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +6 -23
  716. package/queries/catalog/search-query/search-query-format.d.ts +1 -3
  717. package/queries/catalog/search-query/search-query-format.js +3 -11
  718. package/queries/catalog/signature-query/signature-query-executor.d.ts +1 -1
  719. package/queries/catalog/signature-query/signature-query-executor.js +15 -40
  720. package/queries/catalog/signature-query/signature-query-render.d.ts +1 -1
  721. package/queries/catalog/signature-query/signature-query-render.js +6 -4
  722. package/queries/catalog/slice-query-options.d.ts +1 -1
  723. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -4
  724. package/queries/catalog/taint-query/taint-query-format.d.ts +3 -5
  725. package/queries/catalog/taint-query/taint-query-format.js +5 -46
  726. package/queries/query-function-filter.js +7 -33
  727. package/queries/query-function-property.d.ts +1 -1
  728. package/queries/query-function-property.js +4 -7
  729. package/queries/query-meta.d.ts +2 -0
  730. package/queries/query-meta.js +8 -0
  731. package/queries/query-print.d.ts +6 -10
  732. package/queries/query-print.js +20 -75
  733. package/queries/query.d.ts +20 -32
  734. package/queries/query.js +46 -70
  735. package/queries/virtual-query/compound-query.d.ts +2 -7
  736. package/queries/virtual-query/compound-query.js +2 -8
  737. package/queries/virtual-query/virtual-queries.js +1 -3
  738. package/r-bridge/data/get.d.ts +1 -3
  739. package/r-bridge/data/get.js +1 -3
  740. package/r-bridge/lang-4.x/ast/model/model.d.ts +19 -59
  741. package/r-bridge/lang-4.x/ast/model/model.js +9 -27
  742. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -2
  743. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +5 -14
  744. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +2 -6
  745. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +9 -25
  746. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +6 -18
  747. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -8
  748. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -3
  749. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -5
  750. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -2
  751. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -5
  752. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -3
  753. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -5
  754. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -11
  755. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -6
  756. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -2
  757. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -2
  758. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -5
  759. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +4 -11
  760. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +2 -6
  761. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -5
  762. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -7
  763. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -5
  764. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +5 -15
  765. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +3 -10
  766. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +3 -8
  767. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +2 -7
  768. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -2
  769. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -5
  770. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -2
  771. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -8
  772. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -3
  773. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -2
  774. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +4 -14
  775. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +42 -126
  776. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -6
  777. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +1 -3
  778. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +18 -0
  779. package/r-bridge/lang-4.x/ast/model/processing/role.js +25 -0
  780. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -3
  781. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -3
  782. package/r-bridge/lang-4.x/ast/model/syntax-version.js +2 -2
  783. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -5
  784. package/r-bridge/lang-4.x/ast/model/type.js +1 -5
  785. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +5 -17
  786. package/r-bridge/lang-4.x/ast/parser/json/format.js +4 -20
  787. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -3
  788. package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -3
  789. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.d.ts +1 -3
  790. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -7
  791. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.d.ts +1 -3
  792. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -3
  793. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -5
  794. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -10
  795. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +2 -12
  796. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -10
  797. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +1 -10
  798. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +2 -10
  799. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -6
  800. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -7
  801. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.d.ts +1 -3
  802. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +1 -3
  803. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
  804. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +3 -23
  805. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.d.ts +0 -1
  806. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -9
  807. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +1 -10
  808. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-line-directive.js +7 -30
  809. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.d.ts +1 -3
  810. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.js +2 -9
  811. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +3 -9
  812. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +6 -21
  813. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -5
  814. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.d.ts +0 -1
  815. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +0 -1
  816. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +4 -20
  817. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +7 -19
  818. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +8 -26
  819. package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.d.ts +4 -12
  820. package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.js +1 -3
  821. package/r-bridge/lang-4.x/convert-values.d.ts +6 -20
  822. package/r-bridge/lang-4.x/convert-values.js +10 -41
  823. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -5
  824. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -3
  825. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -1
  826. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +39 -208
  827. package/r-bridge/parser.d.ts +1 -3
  828. package/r-bridge/parser.js +1 -4
  829. package/r-bridge/retriever.d.ts +5 -16
  830. package/r-bridge/retriever.js +5 -17
  831. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -1
  832. package/r-bridge/roxygen2/roxygen-ast.d.ts +5 -15
  833. package/r-bridge/roxygen2/roxygen-ast.js +2 -6
  834. package/r-bridge/roxygen2/roxygen-parse.d.ts +2 -1
  835. package/r-bridge/roxygen2/roxygen-parse.js +4 -13
  836. package/r-bridge/shell-executor.d.ts +3 -9
  837. package/r-bridge/shell-executor.js +4 -13
  838. package/r-bridge/shell.d.ts +7 -24
  839. package/r-bridge/shell.js +8 -29
  840. package/reconstruct/auto-select/auto-select-defaults.d.ts +1 -3
  841. package/reconstruct/auto-select/auto-select-defaults.js +1 -3
  842. package/reconstruct/reconstruct.js +5 -15
  843. package/search/flowr-search-builder.d.ts +16 -48
  844. package/search/flowr-search-builder.js +15 -46
  845. package/search/flowr-search-executor.d.ts +1 -3
  846. package/search/flowr-search-executor.js +1 -3
  847. package/search/flowr-search-filters.d.ts +5 -9
  848. package/search/flowr-search-filters.js +4 -13
  849. package/search/flowr-search-printer.d.ts +3 -9
  850. package/search/flowr-search-printer.js +3 -9
  851. package/search/flowr-search-traverse.d.ts +1 -3
  852. package/search/flowr-search-traverse.js +1 -3
  853. package/search/flowr-search.d.ts +6 -19
  854. package/search/search-executor/search-enrichers.d.ts +5 -15
  855. package/search/search-executor/search-enrichers.js +6 -25
  856. package/search/search-executor/search-generators.d.ts +3 -9
  857. package/search/search-executor/search-generators.js +4 -10
  858. package/search/search-executor/search-mappers.d.ts +1 -3
  859. package/search/search-executor/search-mappers.js +1 -3
  860. package/search/search-executor/search-transformer.d.ts +3 -9
  861. package/search/search-executor/search-transformer.js +2 -6
  862. package/search/search-optimizer/search-optimizer.d.ts +1 -4
  863. package/search/search-optimizer/search-optimizer.js +4 -26
  864. package/slicing/criterion/collect-all.d.ts +1 -3
  865. package/slicing/criterion/filters/all-variables.js +2 -9
  866. package/slicing/criterion/parse.d.ts +2 -6
  867. package/slicing/criterion/parse.js +3 -9
  868. package/slicing/static/fingerprint.d.ts +1 -1
  869. package/slicing/static/removal-slice.js +2 -2
  870. package/slicing/static/slice-call.d.ts +2 -4
  871. package/slicing/static/slice-call.js +2 -4
  872. package/slicing/static/slicer-types.d.ts +3 -9
  873. package/slicing/static/static-slicer.d.ts +1 -4
  874. package/slicing/static/static-slicer.js +7 -11
  875. package/slicing/static/visiting-queue.d.ts +0 -1
  876. package/slicing/static/visiting-queue.js +0 -1
  877. package/taint-analysis/builder/domain.d.ts +1 -2
  878. package/taint-analysis/builder/domain.js +1 -6
  879. package/taint-analysis/builder/report-template.d.ts +4 -11
  880. package/taint-analysis/builder/report-template.js +2 -7
  881. package/taint-analysis/builder/taint-analysis-definition.d.ts +2 -3
  882. package/taint-analysis/builder/taint-analysis-definition.js +1 -5
  883. package/taint-analysis/builder/taint-analysis.d.ts +9 -25
  884. package/taint-analysis/builder/taint-analysis.js +1 -3
  885. package/taint-analysis/builtin-index-bridge.js +1 -7
  886. package/taint-analysis/function-categories.d.ts +4 -7
  887. package/taint-analysis/function-categories.js +4 -15
  888. package/taint-analysis/predefined/normalization.js +5 -10
  889. package/taint-analysis/predefined/predefined.d.ts +0 -1
  890. package/taint-analysis/predefined/predefined.js +1 -2
  891. package/taint-analysis/predefined/randomness-analysis.js +4 -16
  892. package/taint-analysis/predefined/secret-analysis.js +2 -8
  893. package/taint-analysis/predefined/security-analysis.js +9 -43
  894. package/taint-analysis/taint-mapping.d.ts +4 -13
  895. package/taint-analysis/taint-mapping.js +3 -9
  896. package/taint-analysis/taint-resolve.d.ts +2 -3
  897. package/taint-analysis/taint-visitor.d.ts +1 -3
  898. package/taint-analysis/taint-visitor.js +2 -2
  899. package/util/arg-matching.js +4 -4
  900. package/util/assert.d.ts +1 -3
  901. package/util/assert.js +2 -5
  902. package/util/collections/arrays.d.ts +9 -30
  903. package/util/collections/arrays.js +5 -18
  904. package/util/collections/defaultmap.d.ts +2 -7
  905. package/util/collections/defaultmap.js +2 -7
  906. package/util/collections/objectmap.d.ts +2 -6
  907. package/util/collections/objectmap.js +2 -6
  908. package/util/collections/set.d.ts +2 -6
  909. package/util/collections/set.js +2 -6
  910. package/util/diff-graph.d.ts +1 -3
  911. package/util/diff-graph.js +2 -8
  912. package/util/diff.d.ts +2 -6
  913. package/util/diff.js +1 -3
  914. package/util/files.d.ts +3 -9
  915. package/util/files.js +3 -9
  916. package/util/flowr-version.d.ts +2 -4
  917. package/util/flowr-version.js +3 -5
  918. package/util/html-hover-over.d.ts +1 -5
  919. package/util/html-hover-over.js +1 -5
  920. package/util/json.d.ts +1 -3
  921. package/util/json.js +1 -3
  922. package/util/log.d.ts +2 -1
  923. package/util/log.js +7 -14
  924. package/util/mermaid/ast.d.ts +3 -7
  925. package/util/mermaid/ast.js +2 -6
  926. package/util/mermaid/cfg.d.ts +2 -4
  927. package/util/mermaid/cfg.js +4 -8
  928. package/util/mermaid/dfg.d.ts +5 -15
  929. package/util/mermaid/dfg.js +20 -16
  930. package/util/mermaid/mermaid.d.ts +4 -13
  931. package/util/mermaid/mermaid.js +5 -19
  932. package/util/numbers.d.ts +1 -3
  933. package/util/numbers.js +1 -3
  934. package/util/objects.d.ts +4 -10
  935. package/util/objects.js +7 -6
  936. package/util/os.d.ts +1 -3
  937. package/util/os.js +1 -3
  938. package/util/parallel.d.ts +1 -4
  939. package/util/parallel.js +1 -4
  940. package/util/proc.js +2 -2
  941. package/util/quads.d.ts +6 -19
  942. package/util/quads.js +2 -7
  943. package/util/r-author.d.ts +1 -3
  944. package/util/r-author.js +2 -10
  945. package/util/r-license.d.ts +2 -6
  946. package/util/r-license.js +10 -43
  947. package/util/r-regex.d.ts +1 -3
  948. package/util/r-regex.js +1 -3
  949. package/util/r-value.d.ts +3 -9
  950. package/util/r-value.js +7 -21
  951. package/util/random.d.ts +1 -3
  952. package/util/random.js +1 -3
  953. package/util/range.d.ts +22 -66
  954. package/util/range.js +22 -66
  955. package/util/schema.d.ts +4 -13
  956. package/util/schema.js +4 -13
  957. package/util/simple-df/dfg-ascii.d.ts +1 -3
  958. package/util/simple-df/dfg-ascii.js +5 -27
  959. package/util/simple-df/dfg-view.d.ts +1 -3
  960. package/util/simple-df/dfg-view.js +1 -3
  961. package/util/slice-direction.d.ts +1 -3
  962. package/util/slice-direction.js +1 -3
  963. package/util/summarizer.d.ts +3 -8
  964. package/util/summarizer.js +1 -3
  965. package/util/text/ansi.d.ts +5 -15
  966. package/util/text/ansi.js +5 -15
  967. package/util/text/args.d.ts +8 -2
  968. package/util/text/args.js +41 -9
  969. package/util/text/playground-link.d.ts +9 -0
  970. package/util/text/playground-link.js +15 -11
  971. package/util/text/r-highlight.js +6 -6
  972. package/util/text/strings.d.ts +6 -19
  973. package/util/text/strings.js +7 -24
  974. package/util/text/time.d.ts +1 -3
  975. package/util/text/time.js +1 -3
  976. package/util/version.d.ts +3 -9
  977. 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 && BareStreamFormats.has(String.fromCodePoint(buf[0]));
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
- if (result === RValues.NilValue) {
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
- for (const signature of CompressionSignatures) {
294
- if (!startsWithMagic(buf, signature.magic) || ('zlibOnly' in signature && signature.zlibOnly && !withZlib)) {
295
- continue;
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
- buffer = zlib.gunzipSync(fileContent, { maxOutputLength: limit });
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
- buffer = zlib.inflateSync(fileContent, { maxOutputLength: limit });
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
- const bzip2 = require('bzip2');
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
- buffer = fileContent;
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
- if (buf.length === 0) {
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
- else if (magic.startsWith('RD')) {
360
- return SerializationTypeTag.MagicMaybeTooNew;
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 (serializationType === SerializationTypeTag.MagicCorrupt ||
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
- switch (String.fromCodePoint(this.buffer[this.offset])) {
393
- case 'A':
394
- this.format = SerializationFormat.Ascii;
395
- break;
396
- case 'B':
397
- this.format = SerializationFormat.Binary;
398
- break;
399
- case 'X':
400
- this.format = SerializationFormat.Xdr;
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.assertInteger(this.inInteger());
415
- const writerVersion = this.assertInteger(this.inInteger());
416
- const minReaderVersion = this.assertInteger(this.inInteger());
417
- switch (version) {
418
- case 2: break;
419
- case 3:
420
- {
421
- const neLen = this.assertInteger(this.inInteger());
422
- if (neLen > RDAParser.R_CODE_SET_MAX || neLen < 0) {
423
- throw new Error('invalid length of encoding name');
424
- }
425
- this.inString(neLen);
426
- break;
427
- }
428
- default:
429
- {
430
- const [vw, pw, sw] = this.decodeVersion(writerVersion);
431
- if (minReaderVersion < 0) {
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
- switch (this.format) {
445
- case SerializationFormat.Ascii: {
446
- const word = this.inWord(128);
447
- if (word === 'NA') {
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
- case SerializationFormat.Xdr: {
462
- const i = this.buffer.readInt32BE(this.offset);
463
- this.offset += 4;
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
- default:
467
- return RValues.NaInteger;
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
- /**. Throws error if `value` is {@link RValues.NaInteger}. */
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
- /**. Throws error if `obj` is {@link RValues.NilValue}. */
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
- while (!this.isSpace(c) && i < size) {
508
- word[i++] = String.fromCodePoint(c);
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 (i >= size) {
512
- throw new Error(`${i} >= ${size} when reading word.`);
467
+ if (word.length >= size) {
468
+ throw new Error(`${word.length} >= ${size} when reading word.`);
513
469
  }
514
- return word.join('');
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
- /**. Answers the next character, or `-1` on EOF. */
476
+ /** . Answers the next character, or `-1` on EOF. */
522
477
  inChar() {
523
- if (this.offset >= this.buffer.length) {
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 === SerializationFormat.Ascii) {
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 v = Math.trunc(writerVersion / RDAParser.MAX_VECTOR_LENGTH);
616
- writerVersion = writerVersion % RDAParser.MAX_VECTOR_LENGTH;
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
- const flags = this.assertInteger(this.inInteger());
629
- return this.readItemRecursive(flags);
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, _hasTag] = this.unpackFlags(flags);
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: return this.getReadRef(this.inRefIndex(flags));
662
- case SexpType.PersistSxp: {
663
- s = this.inStringVec();
664
- this.addReadRef(s);
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
- s = this.inStringVec();
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.currentDepth++;
711
- const info = skip ? this.skipItem() : this.readItem();
712
- const state = skip ? this.skipItem() : this.readItem();
713
- const attr = skip ? this.skipItem() : this.readItem();
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.addReadRef(s);
734
- this.currentDepth++;
735
- this.SetEnClos(s, this.assertRObjectData(skip ? this.skipItem() : this.readItem()));
736
- s.frame = skip ? this.skipItem() : this.readItem();
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.currentDepth++;
772
- s.protected = skip ? this.skipItem() : this.readItem();
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
- case SexpType.WeakRefSxp: {
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.assertInteger(this.inInteger());
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
- const index = r_fun_tab_1.RFunTabOffsets[name];
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.assertInteger(this.inInteger());
690
+ const len = this.readInt();
805
691
  if (len < -1) {
806
692
  throw new Error(`Invalid length ${len} of string.`);
807
693
  }
808
- else if (len == -1) {
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
- if (skip) {
833
- this.inComplexVec(len, true);
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
- this.currentDepth++;
846
- if (skip) {
847
- for (let count = 0; count < len; ++count) {
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
- else {
852
- s.value = new Array(len);
853
- for (let count = 0; count < len; ++count) {
854
- if (type === SexpType.StrSxp) {
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 === SexpType.CharSxp) {
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 (!skip && s.type === SexpType.BcodesSxp) {
919
- return this.R_BytecodeExpr(s);
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.assertInteger(this.inInteger());
926
- const [type, levels, object, hasAttribute, _hasTag] = this.unpackFlags(flags);
927
- const s = {};
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
- s.type = SexpType.EnvSxp;
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
- s.type = SexpType.CharSxp;
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[ix] = Number.parseInt(this.inWord(128), 16);
808
+ result.push(Number.parseInt(this.inWord(128), 16));
980
809
  }
981
810
  }
982
811
  return result;
983
812
  }
984
- if (skip) {
985
- this.offset += len;
986
- return result;
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
- const pType = flags & 255;
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
- const i = index - 1;
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[i];
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
- if (i === 0) {
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.assertInteger(this.inInteger());
1042
- const s = { type: SexpType.CharSxp };
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
- (s.value)[i] = this.readItem();
862
+ value[i] = this.readItem();
1051
863
  }
1052
864
  }
1053
- this.currentDepth--;
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
- let levels, isObject, hasAttr, hasTag;
1085
- [type, levels, isObject, hasAttr, hasTag] = this.unpackFlags(flags);
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.shortcut ? this.skipItem() : this.readItem();
1091
- this.currentDepth--;
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 && (!s.prEnv || s.prEnv === RValues.NilValue)) {
903
+ else if (type === SexpType.PromSxp) {
1103
904
  s.prEnv = RValues.BaseEnv;
1104
905
  }
1105
- flags = this.assertInteger(this.inInteger());
906
+ last.cdr = s;
907
+ last = s;
908
+ flags = this.readInt();
1106
909
  type = flags & 255;
1107
910
  }
1108
- this.currentDepth++;
1109
- const s = this.readItemRecursive(flags);
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 cBuf = this.inString(len);
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.assertInteger(this.inInteger());
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 == -1) {
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
- switch (this.format) {
1212
- case SerializationFormat.Xdr: {
1213
- if (this.offset + 4 * len > this.buffer.length) {
1214
- throw new Error('XDR read failed');
1215
- }
1216
- if (skip) {
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
- case SerializationFormat.Binary:
1228
- throw new Error('No binary support yet.');
1229
- default: {
1230
- const result = [];
1231
- for (let cnt = 0; cnt < len; cnt++) {
1232
- if (skip) {
1233
- this.skipInteger();
1234
- }
1235
- else {
1236
- result[cnt] = this.inInteger();
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
- switch (this.format) {
1249
- case SerializationFormat.Xdr: {
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
- switch (this.format) {
1283
- case SerializationFormat.Ascii: {
1284
- if (skip) {
1285
- this.skipWord();
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
- case SerializationFormat.Binary:
1310
- case SerializationFormat.Xdr: {
1311
- const d = skip ? RValues.NilValue :
1312
- this.format === SerializationFormat.Binary ? this.buffer.readDoubleLE(this.offset) : this.buffer.readDoubleBE(this.offset);
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
- default:
1317
- return RValues.NilValue;
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 !== SexpType.VecSxp &&
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
- if (i < 0 || i >= x.value.length) {
1366
- throw new Error(`attempt to set index ${i}/${x.value.length} in SET_VECTOR_ELT`);
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
- x.value[i] = v;
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
- const reps = { type: SexpType.VecSxp, value: new Array(this.assertInteger(this.inInteger())) };
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
- const s = { type: SexpType.BcodesSxp };
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.assertInteger(this.inInteger());
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
- switch (type) {
1420
- case SexpType.BcodesSxp:
1421
- if (skip) {
1422
- this.skipBC1();
1423
- }
1424
- else {
1425
- this.SET_VECTOR_ELT(ans, i, this.readBC1(reps));
1426
- }
1427
- break;
1428
- case SexpType.LangSxp:
1429
- case SexpType.ListSxp:
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
- switch (type) {
1457
- case SexpType.BcRepRef:
1458
- return this.VECTOR_ELT(reps, this.assertInteger(this.inInteger()));
1459
- case SexpType.BcRepDef:
1460
- case SexpType.LangSxp:
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
- switch (type) {
1509
- case SexpType.BcRepRef:
1510
- this.skipInteger();
1511
- break;
1512
- case SexpType.BcRepDef:
1513
- case SexpType.LangSxp:
1514
- case SexpType.ListSxp:
1515
- case SexpType.AltLangSxp:
1516
- case SexpType.AttrListSxp:
1517
- {
1518
- let hasAttr = false;
1519
- if (type == SexpType.BcRepDef) {
1520
- this.skipInteger();
1521
- type = this.assertInteger(this.inInteger());
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 !== SexpType.VecSxp &&
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
- if (x.altRep) {
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. Throws error if the base type is not a supported vector type.
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
- const clss = this.ALTREP_UNSERIALIZE_CLASS(info);
1586
- if (clss == undefined) {
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
- function walk(n) {
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.name,
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
  }