@blazetrails/ruby-compat 0.0.0-stage → 0.1.0-alpha0.2

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 (625) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +6 -0
  3. package/README.md +440 -2
  4. package/dist/argument-error.d.ts +15 -0
  5. package/dist/argument-error.js +15 -0
  6. package/dist/argument-error.js.map +1 -0
  7. package/dist/array.d.ts +415 -0
  8. package/dist/array.js +1330 -0
  9. package/dist/array.js.map +1 -0
  10. package/dist/async-context-adapter.d.ts +19 -0
  11. package/dist/async-context-adapter.js +139 -0
  12. package/dist/async-context-adapter.js.map +1 -0
  13. package/dist/backtrace-location.d.ts +78 -0
  14. package/dist/backtrace-location.js +158 -0
  15. package/dist/backtrace-location.js.map +1 -0
  16. package/dist/base64.d.ts +73 -0
  17. package/dist/base64.js +164 -0
  18. package/dist/base64.js.map +1 -0
  19. package/dist/benchmark.d.ts +19 -0
  20. package/dist/benchmark.js +16 -0
  21. package/dist/benchmark.js.map +1 -0
  22. package/dist/big-decimal.d.ts +111 -0
  23. package/dist/big-decimal.js +584 -0
  24. package/dist/big-decimal.js.map +1 -0
  25. package/dist/bundler.d.ts +44 -0
  26. package/dist/bundler.js +97 -0
  27. package/dist/bundler.js.map +1 -0
  28. package/dist/cgi.d.ts +89 -0
  29. package/dist/cgi.js +168 -0
  30. package/dist/cgi.js.map +1 -0
  31. package/dist/child-process-adapter.d.ts +110 -0
  32. package/dist/child-process-adapter.js +272 -0
  33. package/dist/child-process-adapter.js.map +1 -0
  34. package/dist/class-module.d.ts +10 -0
  35. package/dist/class-module.js +10 -0
  36. package/dist/class-module.js.map +1 -0
  37. package/dist/classpath.d.ts +93 -0
  38. package/dist/classpath.js +210 -0
  39. package/dist/classpath.js.map +1 -0
  40. package/dist/closed-queue-error.d.ts +10 -0
  41. package/dist/closed-queue-error.js +10 -0
  42. package/dist/closed-queue-error.js.map +1 -0
  43. package/dist/comparable.d.ts +127 -0
  44. package/dist/comparable.js +376 -0
  45. package/dist/comparable.js.map +1 -0
  46. package/dist/complex.d.ts +49 -0
  47. package/dist/complex.js +164 -0
  48. package/dist/complex.js.map +1 -0
  49. package/dist/concurrent/atomic-boolean.d.ts +24 -0
  50. package/dist/concurrent/atomic-boolean.js +43 -0
  51. package/dist/concurrent/atomic-boolean.js.map +1 -0
  52. package/dist/concurrent/atomic-fixnum.d.ts +21 -0
  53. package/dist/concurrent/atomic-fixnum.js +35 -0
  54. package/dist/concurrent/atomic-fixnum.js.map +1 -0
  55. package/dist/concurrent/count-down-latch.d.ts +20 -0
  56. package/dist/concurrent/count-down-latch.js +50 -0
  57. package/dist/concurrent/count-down-latch.js.map +1 -0
  58. package/dist/concurrent/cyclic-barrier.d.ts +18 -0
  59. package/dist/concurrent/cyclic-barrier.js +50 -0
  60. package/dist/concurrent/cyclic-barrier.js.map +1 -0
  61. package/dist/concurrent/event.d.ts +19 -0
  62. package/dist/concurrent/event.js +31 -0
  63. package/dist/concurrent/event.js.map +1 -0
  64. package/dist/concurrent/map.d.ts +149 -0
  65. package/dist/concurrent/map.js +202 -0
  66. package/dist/concurrent/map.js.map +1 -0
  67. package/dist/concurrent/read-write-lock.d.ts +25 -0
  68. package/dist/concurrent/read-write-lock.js +70 -0
  69. package/dist/concurrent/read-write-lock.js.map +1 -0
  70. package/dist/concurrent/semaphore.d.ts +24 -0
  71. package/dist/concurrent/semaphore.js +74 -0
  72. package/dist/concurrent/semaphore.js.map +1 -0
  73. package/dist/concurrent/timer-task.d.ts +52 -0
  74. package/dist/concurrent/timer-task.js +112 -0
  75. package/dist/concurrent/timer-task.js.map +1 -0
  76. package/dist/constants.generated.d.ts +2 -0
  77. package/dist/constants.generated.js +64 -0
  78. package/dist/constants.generated.js.map +1 -0
  79. package/dist/converter-not-found-error.d.ts +14 -0
  80. package/dist/converter-not-found-error.js +14 -0
  81. package/dist/converter-not-found-error.js.map +1 -0
  82. package/dist/crypto-adapter.d.ts +64 -0
  83. package/dist/crypto-adapter.js +365 -0
  84. package/dist/crypto-adapter.js.map +1 -0
  85. package/dist/delegate.d.ts +156 -0
  86. package/dist/delegate.js +306 -0
  87. package/dist/delegate.js.map +1 -0
  88. package/dist/digest.d.ts +99 -0
  89. package/dist/digest.js +131 -0
  90. package/dist/digest.js.map +1 -0
  91. package/dist/dir.d.ts +225 -0
  92. package/dist/dir.js +608 -0
  93. package/dist/dir.js.map +1 -0
  94. package/dist/encoding-error.d.ts +14 -0
  95. package/dist/encoding-error.js +17 -0
  96. package/dist/encoding-error.js.map +1 -0
  97. package/dist/encoding.d.ts +121 -0
  98. package/dist/encoding.js +306 -0
  99. package/dist/encoding.js.map +1 -0
  100. package/dist/ensure.d.ts +15 -0
  101. package/dist/ensure.js +35 -0
  102. package/dist/ensure.js.map +1 -0
  103. package/dist/enumerable.d.ts +375 -0
  104. package/dist/enumerable.js +1102 -0
  105. package/dist/enumerable.js.map +1 -0
  106. package/dist/enumerator.d.ts +324 -0
  107. package/dist/enumerator.js +625 -0
  108. package/dist/enumerator.js.map +1 -0
  109. package/dist/eof-error.d.ts +14 -0
  110. package/dist/eof-error.js +14 -0
  111. package/dist/eof-error.js.map +1 -0
  112. package/dist/errno.d.ts +447 -0
  113. package/dist/errno.js +616 -0
  114. package/dist/errno.js.map +1 -0
  115. package/dist/exc-detailed-message.d.ts +15 -0
  116. package/dist/exc-detailed-message.js +106 -0
  117. package/dist/exc-detailed-message.js.map +1 -0
  118. package/dist/exc-to-s.d.ts +10 -0
  119. package/dist/exc-to-s.js +21 -0
  120. package/dist/exc-to-s.js.map +1 -0
  121. package/dist/exception.d.ts +44 -0
  122. package/dist/exception.js +115 -0
  123. package/dist/exception.js.map +1 -0
  124. package/dist/fiber-error.d.ts +12 -0
  125. package/dist/fiber-error.js +12 -0
  126. package/dist/fiber-error.js.map +1 -0
  127. package/dist/fiber.d.ts +51 -0
  128. package/dist/fiber.js +178 -0
  129. package/dist/fiber.js.map +1 -0
  130. package/dist/file-utils.d.ts +480 -0
  131. package/dist/file-utils.js +1824 -0
  132. package/dist/file-utils.js.map +1 -0
  133. package/dist/file.d.ts +643 -0
  134. package/dist/file.js +1334 -0
  135. package/dist/file.js.map +1 -0
  136. package/dist/float-domain-error.d.ts +17 -0
  137. package/dist/float-domain-error.js +17 -0
  138. package/dist/float-domain-error.js.map +1 -0
  139. package/dist/fork-children.d.ts +23 -0
  140. package/dist/fork-children.js +32 -0
  141. package/dist/fork-children.js.map +1 -0
  142. package/dist/frozen-error.d.ts +33 -0
  143. package/dist/frozen-error.js +41 -0
  144. package/dist/frozen-error.js.map +1 -0
  145. package/dist/fs-adapter.d.ts +158 -0
  146. package/dist/fs-adapter.js +253 -0
  147. package/dist/fs-adapter.js.map +1 -0
  148. package/dist/gem/deprecate.d.ts +10 -0
  149. package/dist/gem/deprecate.js +8 -0
  150. package/dist/gem/deprecate.js.map +1 -0
  151. package/dist/gem/requirement.d.ts +55 -0
  152. package/dist/gem/requirement.js +91 -0
  153. package/dist/gem/requirement.js.map +1 -0
  154. package/dist/gem/version.d.ts +50 -0
  155. package/dist/gem/version.js +148 -0
  156. package/dist/gem/version.js.map +1 -0
  157. package/dist/gem.d.ts +59 -0
  158. package/dist/gem.js +82 -0
  159. package/dist/gem.js.map +1 -0
  160. package/dist/hash.d.ts +967 -0
  161. package/dist/hash.js +1572 -0
  162. package/dist/hash.js.map +1 -0
  163. package/dist/http-adapter.d.ts +124 -0
  164. package/dist/http-adapter.js +220 -0
  165. package/dist/http-adapter.js.map +1 -0
  166. package/dist/immediate-executor.d.ts +20 -0
  167. package/dist/immediate-executor.js +39 -0
  168. package/dist/immediate-executor.js.map +1 -0
  169. package/dist/include.d.ts +778 -0
  170. package/dist/include.js +2208 -0
  171. package/dist/include.js.map +1 -0
  172. package/dist/index-error.d.ts +13 -0
  173. package/dist/index-error.js +13 -0
  174. package/dist/index-error.js.map +1 -0
  175. package/dist/index.d.ts +174 -0
  176. package/dist/index.js +166 -0
  177. package/dist/index.js.map +1 -0
  178. package/dist/invalid-byte-sequence-error.d.ts +62 -0
  179. package/dist/invalid-byte-sequence-error.js +75 -0
  180. package/dist/invalid-byte-sequence-error.js.map +1 -0
  181. package/dist/io-error.d.ts +14 -0
  182. package/dist/io-error.js +17 -0
  183. package/dist/io-error.js.map +1 -0
  184. package/dist/io.d.ts +867 -0
  185. package/dist/io.js +1960 -0
  186. package/dist/io.js.map +1 -0
  187. package/dist/ipaddr.d.ts +79 -0
  188. package/dist/ipaddr.js +405 -0
  189. package/dist/ipaddr.js.map +1 -0
  190. package/dist/json.d.ts +70 -0
  191. package/dist/json.js +181 -0
  192. package/dist/json.js.map +1 -0
  193. package/dist/kernel-catch.d.ts +59 -0
  194. package/dist/kernel-catch.js +184 -0
  195. package/dist/kernel-catch.js.map +1 -0
  196. package/dist/kernel-float.d.ts +19 -0
  197. package/dist/kernel-float.js +54 -0
  198. package/dist/kernel-float.js.map +1 -0
  199. package/dist/kernel-fork.d.ts +30 -0
  200. package/dist/kernel-fork.js +72 -0
  201. package/dist/kernel-fork.js.map +1 -0
  202. package/dist/kernel-format.d.ts +27 -0
  203. package/dist/kernel-format.js +901 -0
  204. package/dist/kernel-format.js.map +1 -0
  205. package/dist/kernel-hash.d.ts +7 -0
  206. package/dist/kernel-hash.js +33 -0
  207. package/dist/kernel-hash.js.map +1 -0
  208. package/dist/kernel-integer.d.ts +49 -0
  209. package/dist/kernel-integer.js +170 -0
  210. package/dist/kernel-integer.js.map +1 -0
  211. package/dist/kernel-rand.d.ts +16 -0
  212. package/dist/kernel-rand.js +237 -0
  213. package/dist/kernel-rand.js.map +1 -0
  214. package/dist/kernel-system.d.ts +39 -0
  215. package/dist/kernel-system.js +103 -0
  216. package/dist/kernel-system.js.map +1 -0
  217. package/dist/kernel-warn.d.ts +35 -0
  218. package/dist/kernel-warn.js +73 -0
  219. package/dist/kernel-warn.js.map +1 -0
  220. package/dist/key-error.d.ts +44 -0
  221. package/dist/key-error.js +59 -0
  222. package/dist/key-error.js.map +1 -0
  223. package/dist/keyword-splat.d.ts +41 -0
  224. package/dist/keyword-splat.js +65 -0
  225. package/dist/keyword-splat.js.map +1 -0
  226. package/dist/load-error.d.ts +19 -0
  227. package/dist/load-error.js +19 -0
  228. package/dist/load-error.js.map +1 -0
  229. package/dist/load.d.ts +128 -0
  230. package/dist/load.js +278 -0
  231. package/dist/load.js.map +1 -0
  232. package/dist/loaded-features.d.ts +13 -0
  233. package/dist/loaded-features.js +15 -0
  234. package/dist/loaded-features.js.map +1 -0
  235. package/dist/local-jump-error.d.ts +12 -0
  236. package/dist/local-jump-error.js +12 -0
  237. package/dist/local-jump-error.js.map +1 -0
  238. package/dist/logger/formatter.d.ts +21 -0
  239. package/dist/logger/formatter.js +43 -0
  240. package/dist/logger/formatter.js.map +1 -0
  241. package/dist/logger/log-device.d.ts +52 -0
  242. package/dist/logger/log-device.js +104 -0
  243. package/dist/logger/log-device.js.map +1 -0
  244. package/dist/logger/severity.d.ts +23 -0
  245. package/dist/logger/severity.js +42 -0
  246. package/dist/logger/severity.js.map +1 -0
  247. package/dist/logger.d.ts +127 -0
  248. package/dist/logger.js +218 -0
  249. package/dist/logger.js.map +1 -0
  250. package/dist/marshal.d.ts +83 -0
  251. package/dist/marshal.js +1487 -0
  252. package/dist/marshal.js.map +1 -0
  253. package/dist/match-data.d.ts +161 -0
  254. package/dist/match-data.js +284 -0
  255. package/dist/match-data.js.map +1 -0
  256. package/dist/method-cache.d.ts +81 -0
  257. package/dist/method-cache.js +109 -0
  258. package/dist/method-cache.js.map +1 -0
  259. package/dist/method-missing-proxy.d.ts +53 -0
  260. package/dist/method-missing-proxy.js +154 -0
  261. package/dist/method-missing-proxy.js.map +1 -0
  262. package/dist/method.d.ts +132 -0
  263. package/dist/method.js +320 -0
  264. package/dist/method.js.map +1 -0
  265. package/dist/monitor.d.ts +114 -0
  266. package/dist/monitor.js +270 -0
  267. package/dist/monitor.js.map +1 -0
  268. package/dist/mutex.d.ts +51 -0
  269. package/dist/mutex.js +150 -0
  270. package/dist/mutex.js.map +1 -0
  271. package/dist/name-error.d.ts +45 -0
  272. package/dist/name-error.js +54 -0
  273. package/dist/name-error.js.map +1 -0
  274. package/dist/net/http/exceptions.d.ts +31 -0
  275. package/dist/net/http/exceptions.js +46 -0
  276. package/dist/net/http/exceptions.js.map +1 -0
  277. package/dist/net/http/request.d.ts +137 -0
  278. package/dist/net/http/request.js +559 -0
  279. package/dist/net/http/request.js.map +1 -0
  280. package/dist/net/http/requests.d.ts +197 -0
  281. package/dist/net/http/requests.js +197 -0
  282. package/dist/net/http/requests.js.map +1 -0
  283. package/dist/net/http/response.d.ts +141 -0
  284. package/dist/net/http/response.js +416 -0
  285. package/dist/net/http/response.js.map +1 -0
  286. package/dist/net/http/responses.d.ts +345 -0
  287. package/dist/net/http/responses.js +486 -0
  288. package/dist/net/http/responses.js.map +1 -0
  289. package/dist/net/http.d.ts +278 -0
  290. package/dist/net/http.js +760 -0
  291. package/dist/net/http.js.map +1 -0
  292. package/dist/net/protocol.d.ts +227 -0
  293. package/dist/net/protocol.js +392 -0
  294. package/dist/net/protocol.js.map +1 -0
  295. package/dist/nil-class.d.ts +10 -0
  296. package/dist/nil-class.js +27 -0
  297. package/dist/nil-class.js.map +1 -0
  298. package/dist/no-method-error.d.ts +38 -0
  299. package/dist/no-method-error.js +45 -0
  300. package/dist/no-method-error.js.map +1 -0
  301. package/dist/not-implemented-error.d.ts +13 -0
  302. package/dist/not-implemented-error.js +13 -0
  303. package/dist/not-implemented-error.js.map +1 -0
  304. package/dist/numeric-class.d.ts +29 -0
  305. package/dist/numeric-class.js +41 -0
  306. package/dist/numeric-class.js.map +1 -0
  307. package/dist/numeric.d.ts +226 -0
  308. package/dist/numeric.js +848 -0
  309. package/dist/numeric.js.map +1 -0
  310. package/dist/object-space.d.ts +34 -0
  311. package/dist/object-space.js +152 -0
  312. package/dist/object-space.js.map +1 -0
  313. package/dist/object.d.ts +833 -0
  314. package/dist/object.js +2131 -0
  315. package/dist/object.js.map +1 -0
  316. package/dist/open-uri.d.ts +180 -0
  317. package/dist/open-uri.js +402 -0
  318. package/dist/open-uri.js.map +1 -0
  319. package/dist/open3.d.ts +69 -0
  320. package/dist/open3.js +134 -0
  321. package/dist/open3.js.map +1 -0
  322. package/dist/openssl.d.ts +479 -0
  323. package/dist/openssl.js +1052 -0
  324. package/dist/openssl.js.map +1 -0
  325. package/dist/optparse.d.ts +130 -0
  326. package/dist/optparse.js +457 -0
  327. package/dist/optparse.js.map +1 -0
  328. package/dist/os-adapter.d.ts +20 -0
  329. package/dist/os-adapter.js +95 -0
  330. package/dist/os-adapter.js.map +1 -0
  331. package/dist/pathname.d.ts +73 -0
  332. package/dist/pathname.js +412 -0
  333. package/dist/pathname.js.map +1 -0
  334. package/dist/pp.d.ts +60 -0
  335. package/dist/pp.js +195 -0
  336. package/dist/pp.js.map +1 -0
  337. package/dist/pretty-print.d.ts +89 -0
  338. package/dist/pretty-print.js +232 -0
  339. package/dist/pretty-print.js.map +1 -0
  340. package/dist/process-adapter.d.ts +229 -0
  341. package/dist/process-adapter.js +889 -0
  342. package/dist/process-adapter.js.map +1 -0
  343. package/dist/process.d.ts +202 -0
  344. package/dist/process.js +433 -0
  345. package/dist/process.js.map +1 -0
  346. package/dist/psych/class-loader.d.ts +92 -0
  347. package/dist/psych/class-loader.js +139 -0
  348. package/dist/psych/class-loader.js.map +1 -0
  349. package/dist/psych/coder.d.ts +144 -0
  350. package/dist/psych/coder.js +176 -0
  351. package/dist/psych/coder.js.map +1 -0
  352. package/dist/psych/core-ext.d.ts +8 -0
  353. package/dist/psych/core-ext.js +10 -0
  354. package/dist/psych/core-ext.js.map +1 -0
  355. package/dist/psych/emitter.d.ts +116 -0
  356. package/dist/psych/emitter.js +1130 -0
  357. package/dist/psych/emitter.js.map +1 -0
  358. package/dist/psych/exception.d.ts +43 -0
  359. package/dist/psych/exception.js +54 -0
  360. package/dist/psych/exception.js.map +1 -0
  361. package/dist/psych/handler.d.ts +59 -0
  362. package/dist/psych/handler.js +95 -0
  363. package/dist/psych/handler.js.map +1 -0
  364. package/dist/psych/handlers/document-stream.d.ts +17 -0
  365. package/dist/psych/handlers/document-stream.js +26 -0
  366. package/dist/psych/handlers/document-stream.js.map +1 -0
  367. package/dist/psych/nodes/alias.d.ts +15 -0
  368. package/dist/psych/nodes/alias.js +22 -0
  369. package/dist/psych/nodes/alias.js.map +1 -0
  370. package/dist/psych/nodes/document.d.ts +23 -0
  371. package/dist/psych/nodes/document.js +35 -0
  372. package/dist/psych/nodes/document.js.map +1 -0
  373. package/dist/psych/nodes/mapping.d.ts +25 -0
  374. package/dist/psych/nodes/mapping.js +35 -0
  375. package/dist/psych/nodes/mapping.js.map +1 -0
  376. package/dist/psych/nodes/node.d.ts +59 -0
  377. package/dist/psych/nodes/node.js +79 -0
  378. package/dist/psych/nodes/node.js.map +1 -0
  379. package/dist/psych/nodes/scalar.d.ts +35 -0
  380. package/dist/psych/nodes/scalar.js +47 -0
  381. package/dist/psych/nodes/scalar.js.map +1 -0
  382. package/dist/psych/nodes/sequence.d.ts +25 -0
  383. package/dist/psych/nodes/sequence.js +35 -0
  384. package/dist/psych/nodes/sequence.js.map +1 -0
  385. package/dist/psych/nodes/stream.d.ts +23 -0
  386. package/dist/psych/nodes/stream.js +31 -0
  387. package/dist/psych/nodes/stream.js.map +1 -0
  388. package/dist/psych/omap.d.ts +9 -0
  389. package/dist/psych/omap.js +9 -0
  390. package/dist/psych/omap.js.map +1 -0
  391. package/dist/psych/parser.d.ts +41 -0
  392. package/dist/psych/parser.js +139 -0
  393. package/dist/psych/parser.js.map +1 -0
  394. package/dist/psych/scalar-scanner.d.ts +31 -0
  395. package/dist/psych/scalar-scanner.js +169 -0
  396. package/dist/psych/scalar-scanner.js.map +1 -0
  397. package/dist/psych/syntax-error.d.ts +23 -0
  398. package/dist/psych/syntax-error.js +35 -0
  399. package/dist/psych/syntax-error.js.map +1 -0
  400. package/dist/psych/tree-builder.d.ts +51 -0
  401. package/dist/psych/tree-builder.js +118 -0
  402. package/dist/psych/tree-builder.js.map +1 -0
  403. package/dist/psych/visitors/depth-first.d.ts +27 -0
  404. package/dist/psych/visitors/depth-first.js +37 -0
  405. package/dist/psych/visitors/depth-first.js.map +1 -0
  406. package/dist/psych/visitors/emitter.d.ts +32 -0
  407. package/dist/psych/visitors/emitter.js +63 -0
  408. package/dist/psych/visitors/emitter.js.map +1 -0
  409. package/dist/psych/visitors/to-ruby.d.ts +110 -0
  410. package/dist/psych/visitors/to-ruby.js +396 -0
  411. package/dist/psych/visitors/to-ruby.js.map +1 -0
  412. package/dist/psych/visitors/visitor.d.ts +11 -0
  413. package/dist/psych/visitors/visitor.js +17 -0
  414. package/dist/psych/visitors/visitor.js.map +1 -0
  415. package/dist/psych/visitors/yaml-tree.d.ts +182 -0
  416. package/dist/psych/visitors/yaml-tree.js +593 -0
  417. package/dist/psych/visitors/yaml-tree.js.map +1 -0
  418. package/dist/psych-adapter.d.ts +65 -0
  419. package/dist/psych-adapter.js +121 -0
  420. package/dist/psych-adapter.js.map +1 -0
  421. package/dist/psych-yaml.d.ts +2 -0
  422. package/dist/psych-yaml.js +5 -0
  423. package/dist/psych-yaml.js.map +1 -0
  424. package/dist/psych.d.ts +257 -0
  425. package/dist/psych.js +332 -0
  426. package/dist/psych.js.map +1 -0
  427. package/dist/queue.d.ts +137 -0
  428. package/dist/queue.js +236 -0
  429. package/dist/queue.js.map +1 -0
  430. package/dist/racc/parser.d.ts +70 -0
  431. package/dist/racc/parser.js +206 -0
  432. package/dist/racc/parser.js.map +1 -0
  433. package/dist/range-error.d.ts +15 -0
  434. package/dist/range-error.js +15 -0
  435. package/dist/range-error.js.map +1 -0
  436. package/dist/range.d.ts +166 -0
  437. package/dist/range.js +421 -0
  438. package/dist/range.js.map +1 -0
  439. package/dist/rational.d.ts +168 -0
  440. package/dist/rational.js +587 -0
  441. package/dist/rational.js.map +1 -0
  442. package/dist/rb-config.d.ts +33 -0
  443. package/dist/rb-config.js +53 -0
  444. package/dist/rb-config.js.map +1 -0
  445. package/dist/rb-equal.d.ts +66 -0
  446. package/dist/rb-equal.js +262 -0
  447. package/dist/rb-equal.js.map +1 -0
  448. package/dist/rb-hash.d.ts +26 -0
  449. package/dist/rb-hash.js +108 -0
  450. package/dist/rb-hash.js.map +1 -0
  451. package/dist/regexp.d.ts +82 -0
  452. package/dist/regexp.js +191 -0
  453. package/dist/regexp.js.map +1 -0
  454. package/dist/repl-adapter.d.ts +270 -0
  455. package/dist/repl-adapter.js +562 -0
  456. package/dist/repl-adapter.js.map +1 -0
  457. package/dist/resolv.d.ts +30 -0
  458. package/dist/resolv.js +48 -0
  459. package/dist/resolv.js.map +1 -0
  460. package/dist/ruby-empty.d.ts +28 -0
  461. package/dist/ruby-empty.js +40 -0
  462. package/dist/ruby-empty.js.map +1 -0
  463. package/dist/ruby-platform.d.ts +39 -0
  464. package/dist/ruby-platform.js +49 -0
  465. package/dist/ruby-platform.js.map +1 -0
  466. package/dist/runtime-error.d.ts +15 -0
  467. package/dist/runtime-error.js +15 -0
  468. package/dist/runtime-error.js.map +1 -0
  469. package/dist/scheduled-task.d.ts +73 -0
  470. package/dist/scheduled-task.js +150 -0
  471. package/dist/scheduled-task.js.map +1 -0
  472. package/dist/secure-random.d.ts +50 -0
  473. package/dist/secure-random.js +141 -0
  474. package/dist/secure-random.js.map +1 -0
  475. package/dist/set.d.ts +158 -0
  476. package/dist/set.js +352 -0
  477. package/dist/set.js.map +1 -0
  478. package/dist/shellwords.d.ts +27 -0
  479. package/dist/shellwords.js +53 -0
  480. package/dist/shellwords.js.map +1 -0
  481. package/dist/signal-exception.d.ts +43 -0
  482. package/dist/signal-exception.js +88 -0
  483. package/dist/signal-exception.js.map +1 -0
  484. package/dist/socket.d.ts +230 -0
  485. package/dist/socket.js +484 -0
  486. package/dist/socket.js.map +1 -0
  487. package/dist/standard-error.d.ts +27 -0
  488. package/dist/standard-error.js +49 -0
  489. package/dist/standard-error.js.map +1 -0
  490. package/dist/stop-iteration.d.ts +10 -0
  491. package/dist/stop-iteration.js +10 -0
  492. package/dist/stop-iteration.js.map +1 -0
  493. package/dist/string/b.d.ts +19 -0
  494. package/dist/string/b.js +28 -0
  495. package/dist/string/b.js.map +1 -0
  496. package/dist/string/byte-methods.d.ts +57 -0
  497. package/dist/string/byte-methods.js +266 -0
  498. package/dist/string/byte-methods.js.map +1 -0
  499. package/dist/string/bytes.d.ts +35 -0
  500. package/dist/string/bytes.js +123 -0
  501. package/dist/string/bytes.js.map +1 -0
  502. package/dist/string/case-mapping.d.ts +57 -0
  503. package/dist/string/case-mapping.js +192 -0
  504. package/dist/string/case-mapping.js.map +1 -0
  505. package/dist/string/chomp.d.ts +15 -0
  506. package/dist/string/chomp.js +32 -0
  507. package/dist/string/chomp.js.map +1 -0
  508. package/dist/string/convert.d.ts +55 -0
  509. package/dist/string/convert.js +316 -0
  510. package/dist/string/convert.js.map +1 -0
  511. package/dist/string/delete.d.ts +14 -0
  512. package/dist/string/delete.js +17 -0
  513. package/dist/string/delete.js.map +1 -0
  514. package/dist/string/each.d.ts +108 -0
  515. package/dist/string/each.js +305 -0
  516. package/dist/string/each.js.map +1 -0
  517. package/dist/string/encode.d.ts +37 -0
  518. package/dist/string/encode.js +268 -0
  519. package/dist/string/encode.js.map +1 -0
  520. package/dist/string/force-encoding.d.ts +72 -0
  521. package/dist/string/force-encoding.js +147 -0
  522. package/dist/string/force-encoding.js.map +1 -0
  523. package/dist/string/inspect.d.ts +17 -0
  524. package/dist/string/inspect.js +81 -0
  525. package/dist/string/inspect.js.map +1 -0
  526. package/dist/string/method-table.d.ts +174 -0
  527. package/dist/string/method-table.js +805 -0
  528. package/dist/string/method-table.js.map +1 -0
  529. package/dist/string/scrub.d.ts +12 -0
  530. package/dist/string/scrub.js +33 -0
  531. package/dist/string/scrub.js.map +1 -0
  532. package/dist/string/slice.d.ts +26 -0
  533. package/dist/string/slice.js +73 -0
  534. package/dist/string/slice.js.map +1 -0
  535. package/dist/string/split.d.ts +11 -0
  536. package/dist/string/split.js +44 -0
  537. package/dist/string/split.js.map +1 -0
  538. package/dist/string/sub.d.ts +114 -0
  539. package/dist/string/sub.js +371 -0
  540. package/dist/string/sub.js.map +1 -0
  541. package/dist/string/succ.d.ts +14 -0
  542. package/dist/string/succ.js +118 -0
  543. package/dist/string/succ.js.map +1 -0
  544. package/dist/string/support.d.ts +142 -0
  545. package/dist/string/support.js +296 -0
  546. package/dist/string/support.js.map +1 -0
  547. package/dist/string/tr.d.ts +46 -0
  548. package/dist/string/tr.js +156 -0
  549. package/dist/string/tr.js.map +1 -0
  550. package/dist/string-io.d.ts +166 -0
  551. package/dist/string-io.js +248 -0
  552. package/dist/string-io.js.map +1 -0
  553. package/dist/string-scanner.d.ts +133 -0
  554. package/dist/string-scanner.js +248 -0
  555. package/dist/string-scanner.js.map +1 -0
  556. package/dist/struct.d.ts +54 -0
  557. package/dist/struct.js +222 -0
  558. package/dist/struct.js.map +1 -0
  559. package/dist/symbol.d.ts +48 -0
  560. package/dist/symbol.js +107 -0
  561. package/dist/symbol.js.map +1 -0
  562. package/dist/tempfile.d.ts +173 -0
  563. package/dist/tempfile.js +295 -0
  564. package/dist/tempfile.js.map +1 -0
  565. package/dist/temporal-tag.d.ts +23 -0
  566. package/dist/temporal-tag.js +29 -0
  567. package/dist/temporal-tag.js.map +1 -0
  568. package/dist/thread-error.d.ts +13 -0
  569. package/dist/thread-error.js +13 -0
  570. package/dist/thread-error.js.map +1 -0
  571. package/dist/thread-pool-executor.d.ts +121 -0
  572. package/dist/thread-pool-executor.js +254 -0
  573. package/dist/thread-pool-executor.js.map +1 -0
  574. package/dist/thread.d.ts +211 -0
  575. package/dist/thread.js +495 -0
  576. package/dist/thread.js.map +1 -0
  577. package/dist/timeout.d.ts +29 -0
  578. package/dist/timeout.js +41 -0
  579. package/dist/timeout.js.map +1 -0
  580. package/dist/tse.d.ts +40 -0
  581. package/dist/tse.js +66 -0
  582. package/dist/tse.js.map +1 -0
  583. package/dist/type-error.d.ts +14 -0
  584. package/dist/type-error.js +14 -0
  585. package/dist/type-error.js.map +1 -0
  586. package/dist/undefined-conversion-error.d.ts +10 -0
  587. package/dist/undefined-conversion-error.js +10 -0
  588. package/dist/undefined-conversion-error.js.map +1 -0
  589. package/dist/uri/common.d.ts +209 -0
  590. package/dist/uri/common.js +369 -0
  591. package/dist/uri/common.js.map +1 -0
  592. package/dist/uri/generic.d.ts +280 -0
  593. package/dist/uri/generic.js +806 -0
  594. package/dist/uri/generic.js.map +1 -0
  595. package/dist/uri/http.d.ts +23 -0
  596. package/dist/uri/http.js +30 -0
  597. package/dist/uri/http.js.map +1 -0
  598. package/dist/uri/https.d.ts +13 -0
  599. package/dist/uri/https.js +15 -0
  600. package/dist/uri/https.js.map +1 -0
  601. package/dist/uri/rfc2396-parser.d.ts +70 -0
  602. package/dist/uri/rfc2396-parser.js +264 -0
  603. package/dist/uri/rfc2396-parser.js.map +1 -0
  604. package/dist/uri/rfc3986-parser.d.ts +46 -0
  605. package/dist/uri/rfc3986-parser.js +171 -0
  606. package/dist/uri/rfc3986-parser.js.map +1 -0
  607. package/dist/uri.d.ts +13 -0
  608. package/dist/uri.js +13 -0
  609. package/dist/uri.js.map +1 -0
  610. package/dist/variable.d.ts +183 -0
  611. package/dist/variable.js +463 -0
  612. package/dist/variable.js.map +1 -0
  613. package/dist/verbose.d.ts +39 -0
  614. package/dist/verbose.js +49 -0
  615. package/dist/verbose.js.map +1 -0
  616. package/dist/yaml.d.ts +9 -0
  617. package/dist/yaml.js +9 -0
  618. package/dist/yaml.js.map +1 -0
  619. package/dist/zlib-adapter.d.ts +119 -0
  620. package/dist/zlib-adapter.js +230 -0
  621. package/dist/zlib-adapter.js.map +1 -0
  622. package/dist/zlib.d.ts +299 -0
  623. package/dist/zlib.js +679 -0
  624. package/dist/zlib.js.map +1 -0
  625. package/package.json +172 -3
@@ -0,0 +1,1487 @@
1
+ import { ArgumentError } from "./argument-error.js";
2
+ import { classpaths } from "./classpath.js";
3
+ import { Encoding } from "./encoding.js";
4
+ import { Hash } from "./hash.js";
5
+ import { Module, extend, prepend, rbDefineAllocFunc, rbGetAllocFunc, rbObjIsKindOf, } from "./include.js";
6
+ import { Range, rangeDumper, rangeLoader } from "./range.js";
7
+ import { warn } from "./kernel-warn.js";
8
+ import { rbBigNorm, rbDbl2num, rbFloatTypeP, rbIntegerTypeP } from "./numeric.js";
9
+ import { Rational, nuratDumper, nuratLoader } from "./rational.js";
10
+ import { FL_SINGLETON, T_ICLASS, isPlainHash, rbFSend, rbInspect, rbModName, rbModSingletonP, rbModToS, rbObjAsString, rbObjClass, rbObjClassname, rbObjInstanceVariables, rbObjIvarDefined, rbObjIvarGet, rbObjIvarSet, RObject, rbIvarForeach, rbIvarSet, rbObjRespondTo, rbObjSingletonClass, rtest, rbCClass, } from "./object.js";
11
+ import { RuntimeError } from "./runtime-error.js";
12
+ import { Set } from "./set.js";
13
+ import { forceEncoding, isValidEncoding } from "./string/force-encoding.js";
14
+ import { rbCheckStringType, stringValue } from "./string/support.js";
15
+ import { isStruct, rbStructInitialize, rstructGet } from "./struct.js";
16
+ import { isSymbol, symbolToS } from "./symbol.js";
17
+ import { temporalTag } from "./temporal-tag.js";
18
+ import { TypeError } from "./type-error.js";
19
+ import { constGet, rbPathToClass } from "./variable.js";
20
+ import { verbose } from "./verbose.js";
21
+ const extendedKeys = Symbol.for("@blazetrails/ruby-compat:extendedKeys");
22
+ const includedModulesKey = Symbol.for("@blazetrails/ruby-compat:includedModules");
23
+ const MARSHAL_MAJOR = 4;
24
+ const MARSHAL_MINOR = 8;
25
+ const TYPE_NIL = 0x30;
26
+ const TYPE_TRUE = 0x54;
27
+ const TYPE_FALSE = 0x46;
28
+ const TYPE_FIXNUM = 0x69;
29
+ const TYPE_UCLASS = 0x43;
30
+ const TYPE_STRUCT = 0x53;
31
+ const TYPE_OBJECT = 0x6f;
32
+ const TYPE_EXTENDED = 0x65;
33
+ const TYPE_USERDEF = 0x75;
34
+ const TYPE_USRMARSHAL = 0x55;
35
+ const TYPE_FLOAT = 0x66;
36
+ const TYPE_BIGNUM = 0x6c;
37
+ const TYPE_STRING = 0x22;
38
+ const TYPE_ARRAY = 0x5b;
39
+ const TYPE_HASH = 0x7b;
40
+ const TYPE_HASH_DEF = 0x7d;
41
+ const TYPE_CLASS = 0x63;
42
+ const TYPE_MODULE = 0x6d;
43
+ const TYPE_SYMBOL = 0x3a;
44
+ const TYPE_SYMLINK = 0x3b;
45
+ const TYPE_IVAR = 0x49;
46
+ const TYPE_LINK = 0x40;
47
+ const FIXNUM_MAX = 2n ** 62n - 1n;
48
+ const FIXNUM_MIN = -(2n ** 62n);
49
+ /** The `arg->data` key of `-0.0`, a heap Float apart from the flonum `0.0` (`vendor/ruby/v3.3.11/marshal.c:896`). */
50
+ const NEGATIVE_ZERO = Symbol("-0.0");
51
+ /** `compat_allocator_tbl` (`vendor/ruby/v3.3.11/marshal.c:127`). */
52
+ const compatAllocatorTbl = new Map();
53
+ /**
54
+ * `rb_marshal_define_compat` (`vendor/ruby/v3.3.11/marshal.c:151`).
55
+ *
56
+ * @noRailsEquivalent PERMANENT
57
+ */
58
+ export function rbMarshalDefineCompat(newclass, oldclass, dumper, loader) {
59
+ const allocator = rbGetAllocFunc(newclass);
60
+ if (!allocator) {
61
+ throw new TypeError("no allocator");
62
+ }
63
+ const compat = { newclass, oldclass, dumper, loader };
64
+ compatAllocatorTbl.set(allocator, compat);
65
+ }
66
+ /** `RB_TYPE_P(obj, T_OBJECT)` (`vendor/ruby/v3.3.11/include/ruby/internal/value_type.h:96`). */
67
+ function tObjectP(obj) {
68
+ return (obj instanceof Set ||
69
+ (Object.prototype.toString.call(obj) === "[object Object]" && rbObjClass(obj) !== Hash));
70
+ }
71
+ /** `must_not_be_anonymous` (`vendor/ruby/v3.3.11/marshal.c:256`). */
72
+ function mustNotBeAnonymous(type, path) {
73
+ if (path[0] === "#") {
74
+ throw new TypeError(`can't dump anonymous ${type} ${path}`);
75
+ }
76
+ return path;
77
+ }
78
+ /**
79
+ * `class2path` (`vendor/ruby/v3.3.11/marshal.c:273`). Every caller hands it
80
+ * a class that is not a singleton, which `rb_class_real` answers unchanged.
81
+ */
82
+ function class2path(klass) {
83
+ const path = rbModName(klass) ?? rbModToS(klass);
84
+ mustNotBeAnonymous(typeof klass === "function" ? "class" : "module", path);
85
+ if (rbPathToClass(path) !== klass) {
86
+ throw new TypeError(`${path} can't be referred to`);
87
+ }
88
+ return path;
89
+ }
90
+ /** `w_nbyte` (`vendor/ruby/v3.3.11/marshal.c:290`). */
91
+ function wNbyte(s, n, arg) {
92
+ for (let i = 0; i < n; i++)
93
+ arg.str.push(s[i]);
94
+ }
95
+ /** `w_byte` (`vendor/ruby/v3.3.11/marshal.c:301`). */
96
+ function wByte(c, arg) {
97
+ wNbyte([c & 0xff], 1, arg);
98
+ }
99
+ /** `w_bytes` (`vendor/ruby/v3.3.11/marshal.c:307`). */
100
+ function wBytes(s, n, arg) {
101
+ wLong(n, arg);
102
+ wNbyte(s, n, arg);
103
+ }
104
+ /** `w_cstr` (`vendor/ruby/v3.3.11/marshal.c:313`). */
105
+ function wCstr(s, arg) {
106
+ const bytes = new TextEncoder().encode(s);
107
+ wBytes(bytes, bytes.length, arg);
108
+ }
109
+ /** `w_short` (`vendor/ruby/v3.3.11/marshal.c:316`). */
110
+ function wShort(x, arg) {
111
+ wByte((x >> 0) & 0xff, arg);
112
+ wByte((x >> 8) & 0xff, arg);
113
+ }
114
+ /** `w_long` (`vendor/ruby/v3.3.11/marshal.c:323`). */
115
+ function wLong(x, arg) {
116
+ const buf = [];
117
+ const i = rubyMarshalWriteLong(x, buf);
118
+ if (i < 0) {
119
+ throw new TypeError("long too big to dump");
120
+ }
121
+ wNbyte(buf, i, arg);
122
+ }
123
+ /** `ruby_marshal_write_long` (`vendor/ruby/v3.3.11/marshal.c:334`). */
124
+ function rubyMarshalWriteLong(x, buf) {
125
+ let i;
126
+ if (x < -0x80000000 || x > 0x7fffffff) {
127
+ return -1;
128
+ }
129
+ if (x === 0) {
130
+ buf[0] = 0;
131
+ return 1;
132
+ }
133
+ if (0 < x && x < 123) {
134
+ buf[0] = x + 5;
135
+ return 1;
136
+ }
137
+ if (-124 < x && x < 0) {
138
+ buf[0] = (x - 5) & 0xff;
139
+ return 1;
140
+ }
141
+ for (i = 1; i < 5; i++) {
142
+ buf[i] = x & 0xff;
143
+ x = x >> 8;
144
+ if (x === 0) {
145
+ buf[0] = i;
146
+ break;
147
+ }
148
+ if (x === -1) {
149
+ buf[0] = -i & 0xff;
150
+ break;
151
+ }
152
+ }
153
+ return i + 1;
154
+ }
155
+ /** `w_float` (`vendor/ruby/v3.3.11/marshal.c:427`). */
156
+ function wFloat(d, arg) {
157
+ if (d === Infinity || d === -Infinity) {
158
+ if (d < 0)
159
+ wCstr("-inf", arg);
160
+ else
161
+ wCstr("inf", arg);
162
+ }
163
+ else if (Number.isNaN(d)) {
164
+ wCstr("nan", arg);
165
+ }
166
+ else if (d === 0.0) {
167
+ if (Object.is(d, -0))
168
+ wCstr("-0", arg);
169
+ else
170
+ wCstr("0", arg);
171
+ }
172
+ else {
173
+ let buf = "";
174
+ const [mant, exp] = Math.abs(d).toExponential().split("e");
175
+ const p = mant.replace(".", "");
176
+ const decpt = Number(exp) + 1;
177
+ const digs = p.length;
178
+ if (d < 0)
179
+ buf += "-";
180
+ if (decpt < -3 || decpt > digs) {
181
+ buf += p[0];
182
+ if (digs - 1 > 0)
183
+ buf += ".";
184
+ buf += p.slice(1);
185
+ buf += `e${decpt - 1}`;
186
+ }
187
+ else if (decpt > 0) {
188
+ buf += p.slice(0, decpt);
189
+ if (digs - decpt > 0) {
190
+ buf += ".";
191
+ buf += p.slice(decpt);
192
+ }
193
+ }
194
+ else {
195
+ buf += "0";
196
+ buf += ".";
197
+ if (decpt) {
198
+ buf += "0".repeat(-decpt);
199
+ }
200
+ buf += p;
201
+ }
202
+ wCstr(buf, arg);
203
+ }
204
+ }
205
+ /** `is_ascii_string` (`vendor/ruby/v3.3.11/marshal.c:484`, `rb_enc_str_asciionly_p`). */
206
+ function isAsciiString(str) {
207
+ for (let i = 0; i < str.length; i++) {
208
+ if (str.charCodeAt(i) > 0x7f)
209
+ return false;
210
+ }
211
+ return true;
212
+ }
213
+ /** `w_encivar` (`vendor/ruby/v3.3.11/marshal.c:480`). */
214
+ function wEncivar(str, arg) {
215
+ const encname = encodingName(str);
216
+ if (encname === null || isAsciiString(str)) {
217
+ return null;
218
+ }
219
+ wByte(TYPE_IVAR, arg);
220
+ return encname;
221
+ }
222
+ /** `w_encname` (`vendor/ruby/v3.3.11/marshal.c:492`). */
223
+ function wEncname(encname, arg) {
224
+ if (encname !== null) {
225
+ wLong(1, arg);
226
+ wEncoding(encname, arg, 1);
227
+ }
228
+ }
229
+ /** `w_symbol` (`vendor/ruby/v3.3.11/marshal.c:504`). */
230
+ function wSymbol(sym, arg) {
231
+ const num = arg.symbols.get(sym);
232
+ if (num !== undefined) {
233
+ wByte(TYPE_SYMLINK, arg);
234
+ wLong(num, arg);
235
+ }
236
+ else {
237
+ const origSym = sym;
238
+ sym = symbolToS(sym);
239
+ const encname = wEncivar(sym, arg);
240
+ wByte(TYPE_SYMBOL, arg);
241
+ wCstr(sym, arg);
242
+ arg.symbols.set(origSym, arg.symbols.size);
243
+ wEncname(encname, arg);
244
+ }
245
+ }
246
+ /** `w_unique` (`vendor/ruby/v3.3.11/marshal.c:528`). */
247
+ function wUnique(s, arg) {
248
+ mustNotBeAnonymous("class", s);
249
+ wSymbol(`:${s}`, arg);
250
+ }
251
+ /** `hash_each` (`vendor/ruby/v3.3.11/marshal.c:537`). */
252
+ function hashEach(key, value, arg, limit) {
253
+ wObject(key, arg, limit);
254
+ wObject(value, arg, limit);
255
+ }
256
+ /**
257
+ * `check_userdump_arg` (`vendor/ruby/v3.3.11/marshal.c:198`), under
258
+ * `dump_funcall` (`marshal.c:210`). `check_dump_arg` (`marshal.c:188`) guards
259
+ * a `dump_arg` a re-entered `Marshal.dump` freed, which a JS object never is.
260
+ */
261
+ function dumpFuncall(obj, sym, name, ...args) {
262
+ const ret = rbFSend(obj, sym, ...args);
263
+ const klass = Object.getPrototypeOf(obj);
264
+ if (ret !== null && typeof ret === "object" && Object.getPrototypeOf(ret) === klass) {
265
+ throw new RuntimeError(`${rbModToS(rbObjClass(obj))}#${name} returned same class instance`);
266
+ }
267
+ return ret;
268
+ }
269
+ /**
270
+ * `SINGLETON_DUMP_UNABLE_P` (`vendor/ruby/v3.3.11/marshal.c:545`): `klass` is
271
+ * the singleton class's method table, its prototype, whose `constructor` seat
272
+ * `rbObjSingletonClass` writes is not a method, nor is any Symbol-keyed seat
273
+ * (`FL_SINGLETON`, the modules an `extend` tracks there).
274
+ */
275
+ function singletonDumpUnableP(klass) {
276
+ return (Object.getOwnPropertyNames(klass).some((mid) => mid !== "constructor") ||
277
+ Object.keys(klass[FL_SINGLETON]).length > 0);
278
+ }
279
+ /**
280
+ * `w_extended` (`vendor/ruby/v3.3.11/marshal.c:550`), over the prototype
281
+ * chain `CLASS_OF(obj)` heads. Nothing is prepended to a singleton class, so
282
+ * `RCLASS_ORIGIN` is the class itself: the `origin != klass` half of the
283
+ * singleton check and the `RICLASS_IS_ORIGIN` guard (`marshal.c:561-562`) have
284
+ * no iclass to meet. `rb_class_name` answers an anonymous module's temporary
285
+ * path, which `w_unique` refuses (`must_not_be_anonymous`, `marshal.c:530`).
286
+ * A plain-object module `extend` copied onto `obj` is recorded on `obj`
287
+ * itself, and stands for the iclass `extend` puts beneath the singleton class.
288
+ */
289
+ function wExtended(obj, arg, check) {
290
+ let klass = Object.getPrototypeOf(obj);
291
+ if (check && klass !== null && Object.hasOwn(klass, FL_SINGLETON)) {
292
+ if (singletonDumpUnableP(klass)) {
293
+ throw new TypeError("singleton can't be dumped");
294
+ }
295
+ klass = Object.getPrototypeOf(klass);
296
+ }
297
+ if (Object.hasOwn(obj, extendedKeys) && Object.hasOwn(obj, includedModulesKey)) {
298
+ for (const m of [...obj[includedModulesKey]].reverse()) {
299
+ wByte(TYPE_EXTENDED, arg);
300
+ wUnique(rbModName(m) ?? rbModToS(m), arg);
301
+ }
302
+ }
303
+ while (klass !== null && Object.hasOwn(klass, T_ICLASS)) {
304
+ const m = klass[T_ICLASS];
305
+ const path = rbModName(m) ?? (m instanceof Module ? m.inspect() : rbModToS(m));
306
+ wByte(TYPE_EXTENDED, arg);
307
+ wUnique(path, arg);
308
+ klass = Object.getPrototypeOf(klass);
309
+ }
310
+ }
311
+ /**
312
+ * `w_class` (`vendor/ruby/v3.3.11/marshal.c:572`). `obj.constructor` is
313
+ * `rb_class_real(CLASS_OF(obj))`: a singleton class's prototype keeps the
314
+ * real class there. A Temporal value has no class of its own: it is the seat
315
+ * of a core class ({@link rbObjClass}), and the class its path names is the
316
+ * constant seated there, which reopens it (`class Date extends rbCDate`).
317
+ *
318
+ * @inventedArm if — PERMANENT
319
+ */
320
+ function wClass(type, obj, arg, check) {
321
+ const realObj = arg.compatTbl?.get(obj);
322
+ if (realObj !== undefined) {
323
+ obj = realObj;
324
+ }
325
+ let klass = obj.constructor;
326
+ if (temporalTag(obj) !== null) {
327
+ klass = constGet(Object, rbModToS(rbObjClass(obj)));
328
+ }
329
+ wExtended(obj, arg, check);
330
+ wByte(type, arg);
331
+ const path = class2path(klass);
332
+ wUnique(path, arg);
333
+ }
334
+ /** `w_uclass` (`vendor/ruby/v3.3.11/marshal.c:590`). */
335
+ function wUclass(obj, sup, arg) {
336
+ const klass = obj.constructor;
337
+ wExtended(obj, arg, true);
338
+ if (klass !== undefined && klass !== sup) {
339
+ wByte(TYPE_UCLASS, arg);
340
+ wUnique(class2path(klass), arg);
341
+ }
342
+ }
343
+ /** `encoding_name` (`vendor/ruby/v3.3.11/marshal.c:661`). */
344
+ function encodingName(obj) {
345
+ if (typeof obj === "string") {
346
+ return true;
347
+ }
348
+ else {
349
+ return null;
350
+ }
351
+ }
352
+ /** `w_encoding` (`vendor/ruby/v3.3.11/marshal.c:694`). */
353
+ function wEncoding(encname, arg, limit) {
354
+ if (limit >= 0)
355
+ ++limit;
356
+ switch (encname) {
357
+ case false:
358
+ case true:
359
+ wSymbol(":E", arg);
360
+ wObject(encname, arg, limit);
361
+ return 1;
362
+ case null:
363
+ return 0;
364
+ }
365
+ wSymbol(":encoding", arg);
366
+ wObject(encname, arg, limit);
367
+ return 1;
368
+ }
369
+ /** @noRailsEquivalent PERMANENT */
370
+ const PLAIN_OBJECT_IVAR = "@__trails_object";
371
+ /**
372
+ * `has_ivars` (`vendor/ruby/v3.3.11/marshal.c:713`). Only a boxed `String` (the
373
+ * ASCII-8BIT String a `_dump` answers) holds ivars, as its own non-index properties.
374
+ *
375
+ * @inventedArm if — PERMANENT
376
+ */
377
+ function hasIvars(obj, encname, arg) {
378
+ let num = encname !== null ? 1 : 0;
379
+ if (obj instanceof String)
380
+ num += Object.keys(obj).length - obj.length;
381
+ else if (arg.markPlainObjects && !(obj instanceof Map) && rbObjIsKindOf(obj, Hash))
382
+ num += 1;
383
+ return num;
384
+ }
385
+ /**
386
+ * `w_ivar_each` (`vendor/ruby/v3.3.11/marshal.c:736`) over `w_obj_each` (`marshal.c:629`).
387
+ *
388
+ * @inventedArm if — PERMANENT
389
+ */
390
+ function wIvarEach(obj, num, arg, limit) {
391
+ if (!num)
392
+ return;
393
+ if (obj instanceof String) {
394
+ for (const id of Object.keys(obj).slice(obj.length)) {
395
+ wSymbol(`:${id}`, arg);
396
+ wObject(obj[id], arg, limit);
397
+ }
398
+ return;
399
+ }
400
+ if (arg.markPlainObjects && !(obj instanceof Map) && rbObjIsKindOf(obj, Hash)) {
401
+ wSymbol(`:${PLAIN_OBJECT_IVAR}`, arg);
402
+ wObject(true, arg, limit);
403
+ return;
404
+ }
405
+ rbIvarForeach(obj, (id, value) => {
406
+ wSymbol(`:${id}`, arg);
407
+ wObject(value, arg, limit);
408
+ });
409
+ }
410
+ /** `w_ivar` (`vendor/ruby/v3.3.11/marshal.c:763`). */
411
+ function wIvar(num, ivobj, encname, arg, limit) {
412
+ wLong(num, arg);
413
+ num -= wEncoding(encname, arg, limit);
414
+ if (ivobj !== undefined && num) {
415
+ wIvarEach(ivobj, num, arg, limit);
416
+ }
417
+ }
418
+ /** `w_objivar` (`vendor/ruby/v3.3.11/marshal.c:780`). */
419
+ function wObjivar(obj, arg, limit) {
420
+ let num = 0;
421
+ rbIvarForeach(obj, () => num++);
422
+ wLong(num, arg);
423
+ wIvarEach(obj, num, arg, limit);
424
+ }
425
+ /** `w_bigfixnum` (`vendor/ruby/v3.3.11/marshal.c:792`). */
426
+ function wBigfixnum(obj, arg) {
427
+ wByte(TYPE_BIGNUM, arg);
428
+ let num = obj;
429
+ const sign = num < 0n ? 0x2d : 0x2b;
430
+ wByte(sign, arg);
431
+ if (num < 0n)
432
+ num = -num;
433
+ let slen = 0;
434
+ {
435
+ let slenNum = num;
436
+ while (slenNum) {
437
+ slen++;
438
+ slenNum = slenNum >> 16n;
439
+ }
440
+ }
441
+ wLong(slen, arg);
442
+ for (let i = 0; i < slen; i++) {
443
+ wShort(Number(num & 0xffffn), arg);
444
+ num = num >> 16n;
445
+ }
446
+ arg.numEntries++;
447
+ }
448
+ /** `w_remember` (`vendor/ruby/v3.3.11/marshal.c:840`). */
449
+ function wRemember(obj, arg) {
450
+ arg.data.set(obj, arg.numEntries++);
451
+ }
452
+ /** `w_object` (`vendor/ruby/v3.3.11/marshal.c:846`). */
453
+ function wObject(obj, arg, limit) {
454
+ let hasiv = 0;
455
+ let encname = null;
456
+ if (limit === 0) {
457
+ throw new ArgumentError("exceed depth limit");
458
+ }
459
+ if (obj === null || obj === undefined) {
460
+ wByte(TYPE_NIL, arg);
461
+ }
462
+ else if (obj === true) {
463
+ wByte(TYPE_TRUE, arg);
464
+ }
465
+ else if (obj === false) {
466
+ wByte(TYPE_FALSE, arg);
467
+ }
468
+ else if (rbIntegerTypeP(obj) && FIXNUM_MIN <= BigInt(obj) && BigInt(obj) <= FIXNUM_MAX) {
469
+ if (-0x40000000 <= obj && obj <= 0x3fffffff) {
470
+ wByte(TYPE_FIXNUM, arg);
471
+ wLong(Number(obj), arg);
472
+ }
473
+ else {
474
+ wBigfixnum(BigInt(obj), arg);
475
+ }
476
+ }
477
+ else if (isSymbol(obj)) {
478
+ wSymbol(obj, arg);
479
+ }
480
+ else {
481
+ if (rbFloatTypeP(obj))
482
+ obj = obj.valueOf();
483
+ else if (rbIntegerTypeP(obj))
484
+ obj = BigInt(obj);
485
+ const key = Object.is(obj, -0) ? NEGATIVE_ZERO : obj;
486
+ const num = arg.data.get(key);
487
+ if (num !== undefined) {
488
+ wByte(TYPE_LINK, arg);
489
+ wLong(num, arg);
490
+ return;
491
+ }
492
+ if (limit > 0)
493
+ limit--;
494
+ if (typeof obj === "number") {
495
+ wRemember(key, arg);
496
+ wByte(TYPE_FLOAT, arg);
497
+ wFloat(obj, arg);
498
+ return;
499
+ }
500
+ if (rbObjRespondTo(obj, "marshalDump")) {
501
+ wRemember(obj, arg);
502
+ const v = dumpFuncall(obj, "marshalDump", "marshal_dump");
503
+ wClass(TYPE_USRMARSHAL, obj, arg, false);
504
+ wObject(v, arg, limit);
505
+ return;
506
+ }
507
+ if (rbObjRespondTo(obj, "_dump")) {
508
+ let ivobj;
509
+ if (arg.userdefs && arg.userdefs.has(obj)) {
510
+ throw new RuntimeError("can't dump recursive object using _dump()");
511
+ }
512
+ const v = dumpFuncall(obj, "_dump", "_dump", limit);
513
+ if (!(typeof v === "string" || v instanceof String)) {
514
+ throw new TypeError("_dump() must return string");
515
+ }
516
+ hasiv = hasIvars(obj, (encname = encodingName(obj)), arg);
517
+ const encname2 = encodingName(v);
518
+ const hasiv2 = hasIvars(v, encname2, arg);
519
+ if (hasiv2) {
520
+ hasiv = hasiv2;
521
+ ivobj = v;
522
+ encname = encname2;
523
+ }
524
+ if (hasiv)
525
+ wByte(TYPE_IVAR, arg);
526
+ wClass(TYPE_USERDEF, obj, arg, false);
527
+ if (typeof v === "string") {
528
+ wCstr(v, arg);
529
+ }
530
+ else {
531
+ const bytes = Array.from({ length: v.length }, (_, i) => v.charCodeAt(i));
532
+ wBytes(bytes, bytes.length, arg);
533
+ }
534
+ if (hasiv) {
535
+ (arg.userdefs ??= new globalThis.Set()).add(obj);
536
+ wIvar(hasiv, ivobj, encname, arg, limit);
537
+ arg.userdefs.delete(obj);
538
+ }
539
+ wRemember(obj, arg);
540
+ return;
541
+ }
542
+ wRemember(key, arg);
543
+ hasiv = hasIvars(obj, (encname = encodingName(obj)), arg);
544
+ {
545
+ const allocator = rbGetAllocFunc(rbObjClass(obj));
546
+ const compat = allocator === undefined ? undefined : compatAllocatorTbl.get(allocator);
547
+ if (compat !== undefined) {
548
+ const realObj = obj;
549
+ obj = compat.dumper(realObj);
550
+ if (!arg.compatTbl) {
551
+ arg.compatTbl = new Map();
552
+ }
553
+ arg.compatTbl.set(obj, realObj);
554
+ if (obj !== realObj && encname === null)
555
+ hasiv = 0;
556
+ }
557
+ }
558
+ if (hasiv)
559
+ wByte(TYPE_IVAR, arg);
560
+ if (typeof obj === "function" && rbObjClass(obj) === rbCClass) {
561
+ if (rbModSingletonP(obj)) {
562
+ throw new TypeError("singleton class can't be dumped");
563
+ }
564
+ {
565
+ const path = class2path(obj);
566
+ const encname = wEncivar(path, arg);
567
+ wByte(TYPE_CLASS, arg);
568
+ wCstr(path, arg);
569
+ wEncname(encname, arg);
570
+ }
571
+ }
572
+ else if (obj instanceof Module || (isPlainHash(obj) && classpaths.has(obj))) {
573
+ const path = class2path(obj);
574
+ const encname = wEncivar(path, arg);
575
+ wByte(TYPE_MODULE, arg);
576
+ wCstr(path, arg);
577
+ wEncname(encname, arg);
578
+ }
579
+ else if (typeof obj === "bigint") {
580
+ wByte(TYPE_BIGNUM, arg);
581
+ {
582
+ const sign = obj >= 0n ? 0x2b : 0x2d;
583
+ const d = [];
584
+ for (let num = obj < 0n ? -obj : obj; num; num = num >> 16n) {
585
+ d.push(Number(num & 0xffffn));
586
+ }
587
+ wByte(sign, arg);
588
+ wLong(d.length, arg);
589
+ for (let j = 0; j < d.length; j++) {
590
+ wShort(d[j], arg);
591
+ }
592
+ }
593
+ }
594
+ else if (typeof obj === "string") {
595
+ wByte(TYPE_STRING, arg);
596
+ wCstr(obj, arg);
597
+ }
598
+ else if (obj instanceof Uint8Array) {
599
+ wByte(TYPE_STRING, arg);
600
+ wBytes(obj, obj.length, arg);
601
+ }
602
+ else if (Array.isArray(obj)) {
603
+ wUclass(obj, Array, arg);
604
+ wByte(TYPE_ARRAY, arg);
605
+ {
606
+ const len = obj.length;
607
+ wLong(len, arg);
608
+ for (let i = 0; i < obj.length; i++) {
609
+ wObject(obj[i], arg, limit);
610
+ if (len !== obj.length) {
611
+ throw new RuntimeError("array modified during dump");
612
+ }
613
+ }
614
+ }
615
+ }
616
+ else if (obj instanceof Map || rbObjIsKindOf(obj, Hash)) {
617
+ wUclass(obj, obj instanceof Hash ? Hash : obj instanceof Map ? Map : Object, arg);
618
+ if (obj instanceof Hash && obj.isCompareByIdentity()) {
619
+ wByte(TYPE_UCLASS, arg);
620
+ wSymbol(":Hash", arg);
621
+ }
622
+ const ifnone = obj instanceof Hash ? (obj.defaultProc() ?? obj.default()) : undefined;
623
+ if (ifnone == null) {
624
+ wByte(TYPE_HASH, arg);
625
+ }
626
+ else if (obj instanceof Hash && obj.defaultProc() !== undefined) {
627
+ throw new TypeError("can't dump hash with default proc");
628
+ }
629
+ else {
630
+ wByte(TYPE_HASH_DEF, arg);
631
+ }
632
+ const pairs = obj instanceof Map ? [...obj] : Object.entries(obj);
633
+ wLong(pairs.length, arg);
634
+ for (const [key, value] of pairs)
635
+ hashEach(key, value, arg, limit);
636
+ if (ifnone != null) {
637
+ wObject(ifnone, arg, limit);
638
+ }
639
+ }
640
+ else if (isStruct(obj)) {
641
+ wClass(TYPE_STRUCT, obj, arg, true);
642
+ {
643
+ const mem = obj.members();
644
+ const len = mem.length;
645
+ wLong(len, arg);
646
+ for (let i = 0; i < len; i++) {
647
+ wSymbol(`:${mem[i]}`, arg);
648
+ wObject(rstructGet(obj, i), arg, limit);
649
+ }
650
+ }
651
+ }
652
+ else if (tObjectP(obj)) {
653
+ wClass(TYPE_OBJECT, obj, arg, true);
654
+ wObjivar(obj, arg, limit);
655
+ }
656
+ else {
657
+ throw new TypeError(`no _dump_data is defined for class ${rbObjClassname(obj)}`);
658
+ }
659
+ }
660
+ if (hasiv) {
661
+ wIvar(hasiv, arg.markPlainObjects && !(obj instanceof Map) && rbObjIsKindOf(obj, Hash)
662
+ ? obj
663
+ : undefined, encname, arg, limit);
664
+ }
665
+ }
666
+ /** `rb_marshal_dump_limited` (`vendor/ruby/v3.3.11/marshal.c:1228`). */
667
+ function rbMarshalDumpLimited(obj, limit, markPlainObjects) {
668
+ const arg = {
669
+ str: [],
670
+ symbols: new Map(),
671
+ data: new Map(),
672
+ numEntries: 0,
673
+ compatTbl: null,
674
+ userdefs: null,
675
+ markPlainObjects,
676
+ };
677
+ wByte(MARSHAL_MAJOR, arg);
678
+ wByte(MARSHAL_MINOR, arg);
679
+ wObject(obj, arg, limit);
680
+ return Uint8Array.from(arg.str);
681
+ }
682
+ /** `too_short` (`vendor/ruby/v3.3.11/marshal.c:1337`). */
683
+ function tooShort() {
684
+ throw new ArgumentError("marshal data too short");
685
+ }
686
+ /** `r_prepare` (`vendor/ruby/v3.3.11/marshal.c:1343`); `undefined` is `Qundef`. */
687
+ function rPrepare(arg) {
688
+ const idx = arg.data.size;
689
+ arg.data.set(idx, undefined);
690
+ return idx;
691
+ }
692
+ /** `r_byte` (`vendor/ruby/v3.3.11/marshal.c:1370`), the String-source arm. */
693
+ function rByte(arg) {
694
+ let c;
695
+ if (arg.src.length > arg.offset) {
696
+ c = arg.src.charCodeAt(arg.offset++) & 0xff;
697
+ }
698
+ else {
699
+ tooShort();
700
+ }
701
+ return c;
702
+ }
703
+ /** `long_toobig` (`vendor/ruby/v3.3.11/marshal.c:1398`). */
704
+ function longToobig(size) {
705
+ throw new TypeError(`long too big for this architecture (size 8, given ${size})`);
706
+ }
707
+ /**
708
+ * `r_long` (`vendor/ruby/v3.3.11/marshal.c:1405`). JS's bitwise operators are
709
+ * 32-bit, so the bytes are summed; the negative arm's mask-and-or over `-1` is
710
+ * the same value less `256 ** c`. `w_long` writes four bytes at most; a wider
711
+ * payload is exact up to `2 ** 53`, where a C `long` is to `2 ** 63`.
712
+ */
713
+ function rLong(arg) {
714
+ let x;
715
+ let c = (rByte(arg) << 24) >> 24;
716
+ if (c === 0)
717
+ return 0;
718
+ if (c > 0) {
719
+ if (4 < c && c < 128) {
720
+ return c - 5;
721
+ }
722
+ if (c > 8)
723
+ longToobig(c);
724
+ x = 0;
725
+ for (let i = 0; i < c; i++) {
726
+ x += rByte(arg) * 256 ** i;
727
+ }
728
+ }
729
+ else {
730
+ if (-129 < c && c < -4) {
731
+ return c + 5;
732
+ }
733
+ c = -c;
734
+ if (c > 8)
735
+ longToobig(c);
736
+ x = -(256 ** c);
737
+ for (let i = 0; i < c; i++) {
738
+ x += rByte(arg) * 256 ** i;
739
+ }
740
+ }
741
+ return x;
742
+ }
743
+ /** `r_bytes` (`vendor/ruby/v3.3.11/marshal.c:1507`). */
744
+ function rBytes(arg) {
745
+ return rBytes0(rLong(arg), arg);
746
+ }
747
+ /** `r_bytes0` (`vendor/ruby/v3.3.11/marshal.c:1510`), the String-source arm: an ASCII-8BIT String. */
748
+ function rBytes0(len, arg) {
749
+ let str;
750
+ if (len === 0)
751
+ return "";
752
+ if (arg.src.length - arg.offset >= len) {
753
+ str = arg.src.slice(arg.offset, arg.offset + len);
754
+ arg.offset += len;
755
+ }
756
+ else {
757
+ tooShort();
758
+ }
759
+ return str;
760
+ }
761
+ /**
762
+ * `sym2encidx` (`vendor/ruby/v3.3.11/marshal.c:1543`); `null` is its `-1`, which
763
+ * `rb_enc_find_index` also answers for a name that is not registered. Like
764
+ * `Encoding.find`, it resolves the `external` and `locale` aliases.
765
+ */
766
+ function sym2encidx(sym, val) {
767
+ if (!isAsciiString(sym))
768
+ return null;
769
+ if (sym.length <= 0)
770
+ return null;
771
+ if (sym === "encoding") {
772
+ const name = stringValue(val);
773
+ if (name.includes("\0"))
774
+ throw new ArgumentError("string contains null byte");
775
+ try {
776
+ return Encoding.find(name);
777
+ }
778
+ catch (e) {
779
+ if (!(e instanceof ArgumentError))
780
+ throw e;
781
+ return null;
782
+ }
783
+ }
784
+ if (sym === "E") {
785
+ if (val === false)
786
+ return Encoding.US_ASCII;
787
+ else if (val === true)
788
+ return Encoding.UTF_8;
789
+ }
790
+ return null;
791
+ }
792
+ /** `r_symlink` (`vendor/ruby/v3.3.11/marshal.c:1580`). */
793
+ function rSymlink(arg) {
794
+ const num = rLong(arg);
795
+ const sym = arg.symbols[num];
796
+ if (sym === undefined) {
797
+ throw new ArgumentError("bad symbol");
798
+ }
799
+ return sym;
800
+ }
801
+ /**
802
+ * `r_symreal` (`vendor/ruby/v3.3.11/marshal.c:1592`). Its US-ASCII tag for an
803
+ * ascii-only symbol (`marshal.c:1598`) has no JS string to sit on.
804
+ */
805
+ function rSymreal(arg, ivar) {
806
+ let s = rBytes(arg);
807
+ let idx = null;
808
+ const n = arg.symbols.length;
809
+ arg.symbols[n] = s;
810
+ if (ivar) {
811
+ let num = rLong(arg);
812
+ while (num-- > 0) {
813
+ const sym = rSymbol(arg);
814
+ idx = sym2encidx(sym, rObject(arg));
815
+ }
816
+ }
817
+ if (idx !== null && idx !== Encoding.ASCII_8BIT) {
818
+ if (!isValidEncoding(s, idx)) {
819
+ throw new ArgumentError(`invalid byte sequence in ${idx.name}: ${rbInspect(s)}`);
820
+ }
821
+ arg.symbols[n] = s = forceEncoding(s, idx);
822
+ }
823
+ return s;
824
+ }
825
+ /** `r_symbol` (`vendor/ruby/v3.3.11/marshal.c:1620`). */
826
+ function rSymbol(arg) {
827
+ let type;
828
+ let ivar = false;
829
+ for (;;) {
830
+ switch ((type = rByte(arg))) {
831
+ default:
832
+ throw new ArgumentError(`dump format error for symbol(0x${type.toString(16)})`);
833
+ case TYPE_IVAR:
834
+ ivar = true;
835
+ continue;
836
+ case TYPE_SYMBOL:
837
+ return rSymreal(arg, ivar);
838
+ case TYPE_SYMLINK:
839
+ if (ivar) {
840
+ throw new ArgumentError("dump format error (symlink with encoding)");
841
+ }
842
+ return rSymlink(arg);
843
+ }
844
+ }
845
+ }
846
+ /** `r_unique` (`vendor/ruby/v3.3.11/marshal.c:1642`). */
847
+ function rUnique(arg) {
848
+ return rSymbol(arg);
849
+ }
850
+ /** `r_string` (`vendor/ruby/v3.3.11/marshal.c:1648`). */
851
+ function rString(arg) {
852
+ return rBytes(arg);
853
+ }
854
+ /** `r_entry0` (`vendor/ruby/v3.3.11/marshal.c:1654`). */
855
+ function rEntry0(v, num, arg) {
856
+ let realObj = v;
857
+ if (arg.compatTbl) {
858
+ realObj = arg.compatTbl.get(v) ?? v;
859
+ }
860
+ arg.data.set(num, realObj);
861
+ return v;
862
+ }
863
+ /** `r_fixup_compat` (`vendor/ruby/v3.3.11/marshal.c:1667`). */
864
+ function rFixupCompat(v, arg) {
865
+ const realObj = arg.compatTbl?.get(v);
866
+ if (realObj !== undefined) {
867
+ arg.compatTbl.delete(v);
868
+ const allocator = rbGetAllocFunc(rbObjClass(realObj));
869
+ const compat = allocator === undefined ? undefined : compatAllocatorTbl.get(allocator);
870
+ if (compat !== undefined) {
871
+ compat.loader(realObj, v);
872
+ }
873
+ v = realObj;
874
+ }
875
+ return v;
876
+ }
877
+ /**
878
+ * `r_leave` (`vendor/ruby/v3.3.11/marshal.c:1693`). `arg->partial_objects`,
879
+ * `arg->freeze` and `r_post_proc` serve `Marshal.load`'s `proc` and `freeze:`,
880
+ * which are not ported.
881
+ */
882
+ function rLeave(v, arg) {
883
+ v = rFixupCompat(v, arg);
884
+ return v;
885
+ }
886
+ /** `r_entry` (`vendor/ruby/v3.3.11/marshal.c:1331`). */
887
+ function rEntry(v, arg) {
888
+ return rEntry0(v, arg.data.size, arg);
889
+ }
890
+ /**
891
+ * `r_ivar_encoding` (`vendor/ruby/v3.3.11/marshal.c:1734`). `rb_enc_associate_index`
892
+ * retags a Ruby String in place; a JS string is immutable, so the re-read
893
+ * string is answered, and `undefined` is the C `FALSE`.
894
+ */
895
+ function rIvarEncoding(obj, arg, sym, val) {
896
+ const idx = sym2encidx(sym, val);
897
+ if (idx !== null) {
898
+ if (obj instanceof Uint8Array) {
899
+ let str = "";
900
+ for (const byte of obj)
901
+ str += String.fromCharCode(byte);
902
+ return forceEncoding(str, idx);
903
+ }
904
+ else if (typeof obj === "string") {
905
+ return forceEncoding(obj, idx);
906
+ }
907
+ else if (obj instanceof String) {
908
+ return new String(forceEncoding(obj.valueOf(), idx));
909
+ }
910
+ else {
911
+ throw new ArgumentError(`${rbObjAsString(obj)} is not enc_capable`);
912
+ }
913
+ }
914
+ return undefined;
915
+ }
916
+ /**
917
+ * `r_encname` (`vendor/ruby/v3.3.11/marshal.c:1750`). `obj` holds the String
918
+ * `rb_enc_associate_index` retags in place, and is left holding the re-read one.
919
+ */
920
+ function rEncname(obj, arg) {
921
+ let len = rLong(arg);
922
+ if (len > 0) {
923
+ const sym = rSymbol(arg);
924
+ const val = rObject(arg);
925
+ const str = rIvarEncoding(obj.value, arg, sym, val);
926
+ if (str !== undefined)
927
+ obj.value = str;
928
+ len -= str !== undefined ? 1 : 0;
929
+ }
930
+ return len;
931
+ }
932
+ /**
933
+ * `r_ivar` (`vendor/ruby/v3.3.11/marshal.c:1762`), answering `obj` as
934
+ * {@link rIvarEncoding} left it. `rb_hash_ruby2_keywords` flags a Hash as
935
+ * keyword arguments, which a JS call has no slot for.
936
+ *
937
+ * @inventedArm if — PERMANENT
938
+ */
939
+ function rIvar(obj, hasEncoding, arg, idx = -1) {
940
+ let len = rLong(arg);
941
+ if (len > 0) {
942
+ do {
943
+ const sym = rSymbol(arg);
944
+ const val = rObject(arg);
945
+ const str = rIvarEncoding(obj, arg, sym, val);
946
+ if (str !== undefined) {
947
+ if (hasEncoding)
948
+ hasEncoding.value = true;
949
+ obj = str;
950
+ }
951
+ else if (sym === "K") {
952
+ if (!(obj instanceof Map)) {
953
+ throw new ArgumentError(`ruby2_keywords flag is given but ${rbObjAsString(obj)} is not a Hash`);
954
+ }
955
+ }
956
+ else if (sym === PLAIN_OBJECT_IVAR && obj instanceof Hash) {
957
+ if (!arg.links.has(idx) && [...obj.keys()].every((key) => typeof key === "string")) {
958
+ obj = Object.fromEntries(obj);
959
+ }
960
+ }
961
+ else if (obj instanceof String) {
962
+ obj[sym] = val;
963
+ }
964
+ else {
965
+ rbIvarSet(obj, sym, val);
966
+ }
967
+ } while (--len > 0);
968
+ }
969
+ return obj;
970
+ }
971
+ /**
972
+ * `r_copy_ivar` (`vendor/ruby/v3.3.11/marshal.c:1727`), over `copy_ivar_i`
973
+ * (`marshal.c:1716`). Only a `T_OBJECT` carries ivars here: a JS Array, Hash
974
+ * or String has no ivar table.
975
+ *
976
+ * @inventedArm if — PERMANENT
977
+ */
978
+ function rCopyIvar(v, data) {
979
+ if (tObjectP(data)) {
980
+ for (const vid of rbObjInstanceVariables(data)) {
981
+ if (!rbObjIvarDefined(v, vid))
982
+ rbObjIvarSet(v, vid, rbObjIvarGet(data, vid));
983
+ }
984
+ }
985
+ return v;
986
+ }
987
+ /** `path2class` (`vendor/ruby/v3.3.11/marshal.c:1790`). */
988
+ function path2class(path) {
989
+ const v = rbPathToClass(path);
990
+ if (!(typeof v === "function" && rbObjClass(v) === rbCClass)) {
991
+ throw new ArgumentError(`${path} does not refer to class`);
992
+ }
993
+ return v;
994
+ }
995
+ /** `must_be_module` (`vendor/ruby/v3.3.11/marshal.c:1803`), under `path2module` (`marshal.c:1800`). */
996
+ function mustBeModule(v, path) {
997
+ if (!(v instanceof Module || isPlainHash(v))) {
998
+ throw new ArgumentError(`${path} does not refer to module`);
999
+ }
1000
+ return v;
1001
+ }
1002
+ /**
1003
+ * `rb_obj_alloc` (`vendor/ruby/v3.3.11/object.c:2117`): the class's allocator
1004
+ * (`rb_get_alloc_func`), never `initialize`. `rb_class_allocate_instance`
1005
+ * (`vendor/ruby/v3.3.11/gc.c:3120`), the allocator of `Object`, is `Object.create`.
1006
+ */
1007
+ function rbObjAlloc(klass) {
1008
+ const allocator = rbGetAllocFunc(klass);
1009
+ if (allocator)
1010
+ return allocator(klass);
1011
+ return Object.create(klass.prototype);
1012
+ }
1013
+ /** `obj_alloc_by_klass` (`vendor/ruby/v3.3.11/marshal.c:1812`). */
1014
+ function objAllocByKlass(klass, arg, oldclass) {
1015
+ const allocator = rbGetAllocFunc(klass);
1016
+ const compat = allocator === undefined ? undefined : compatAllocatorTbl.get(allocator);
1017
+ if (compat !== undefined) {
1018
+ const realObj = rbObjAlloc(klass);
1019
+ const obj = rbObjAlloc(compat.oldclass);
1020
+ if (oldclass)
1021
+ oldclass.value = compat.oldclass;
1022
+ if (!arg.compatTbl) {
1023
+ arg.compatTbl = new Map();
1024
+ }
1025
+ arg.compatTbl.set(obj, realObj);
1026
+ return obj;
1027
+ }
1028
+ return rbObjAlloc(klass);
1029
+ }
1030
+ /** `obj_alloc_by_path` (`vendor/ruby/v3.3.11/marshal.c:1835`). */
1031
+ function objAllocByPath(path, arg) {
1032
+ return objAllocByKlass(path2class(path), arg, null);
1033
+ }
1034
+ /** `append_extmod` (`vendor/ruby/v3.3.11/marshal.c:1841`). */
1035
+ function appendExtmod(obj, extmod) {
1036
+ let i = extmod.length;
1037
+ while (i > 0) {
1038
+ const m = extmod[--i];
1039
+ m.extendObject(obj);
1040
+ }
1041
+ return obj;
1042
+ }
1043
+ /** `prohibit_ivar` (`vendor/ruby/v3.3.11/marshal.c:1852`). */
1044
+ function prohibitIvar(type, str, ivp) {
1045
+ if (!ivp || !ivp.value)
1046
+ return;
1047
+ throw new TypeError(`can't override instance variable of ${type} \`${str}'`);
1048
+ }
1049
+ /** `r_object0` (`vendor/ruby/v3.3.11/marshal.c:1861`). */
1050
+ function rObject0(arg, ivp, extmod) {
1051
+ const type = rByte(arg);
1052
+ return rObjectFor(arg, ivp, extmod, type);
1053
+ }
1054
+ /**
1055
+ * `r_object_for` (`vendor/ruby/v3.3.11/marshal.c:1868`). The loop stands in
1056
+ * for `goto type_hash`. `Marshal.load`'s `proc` and `freeze:` are not ported,
1057
+ * which leaves `r_leave` (`marshal.c:1693`) its `r_fixup_compat`. `load_mantissa`
1058
+ * (`marshal.c:386`) reads the mantissa bytes format 4.8 no longer writes, and
1059
+ * `rb_integer_unpack` and `ULONG2NUM` are the BigInt shifts. `TYPE_IVAR`
1060
+ * re-enters at its `arg->data` index the String `r_ivar` re-read, where
1061
+ * `rb_enc_associate_index` retags a Ruby String in place; a linked String has
1062
+ * no entry of its own to re-enter. `TYPE_UCLASS` reaches a String, an Array,
1063
+ * a Hash or a Module, and `TYPE(v) != TYPE(tmp)` compares those. The arms
1064
+ * {@link wObject} does not write are not read either, and take the `default:`
1065
+ * arm.
1066
+ *
1067
+ * @inventedArm rEntry0 — PERMANENT
1068
+ */
1069
+ function rObjectFor(arg, ivp, extmod, type) {
1070
+ let v;
1071
+ let hashNewWithSize = () => new Hash();
1072
+ for (;;) {
1073
+ switch (type) {
1074
+ case TYPE_LINK: {
1075
+ const id = rLong(arg);
1076
+ if (!arg.data.has(id)) {
1077
+ throw new ArgumentError("dump format error (unlinked)");
1078
+ }
1079
+ v = arg.data.get(id);
1080
+ arg.links.add(id);
1081
+ break;
1082
+ }
1083
+ case TYPE_IVAR: {
1084
+ const ivar = { value: true };
1085
+ const idx = arg.data.size;
1086
+ v = rObject0(arg, ivar, extmod);
1087
+ if (ivar.value) {
1088
+ const obj = rIvar(v, null, arg, idx);
1089
+ if (obj !== v && arg.data.get(idx) === v)
1090
+ v = rEntry0(obj, idx, arg);
1091
+ }
1092
+ break;
1093
+ }
1094
+ case TYPE_EXTENDED: {
1095
+ const path = rUnique(arg);
1096
+ let m = rbPathToClass(path);
1097
+ if (extmod === null)
1098
+ extmod = [];
1099
+ if (typeof m === "function" && rbObjClass(m) === rbCClass) {
1100
+ v = rObject0(arg, null, null);
1101
+ const c = Object.getPrototypeOf(v);
1102
+ if (c !== m.prototype) {
1103
+ throw new ArgumentError(`prepended class ${path} differs from class ${rbObjClassname(v)}`);
1104
+ }
1105
+ const singleton = rbObjSingletonClass(v);
1106
+ while (extmod.length > 0) {
1107
+ m = extmod.pop();
1108
+ prepend(singleton, m);
1109
+ }
1110
+ }
1111
+ else {
1112
+ mustBeModule(m, path);
1113
+ extmod.push(m);
1114
+ v = rObject0(arg, null, extmod);
1115
+ while (extmod.length > 0) {
1116
+ m = extmod.pop();
1117
+ extend(v, m);
1118
+ }
1119
+ }
1120
+ v = rLeave(v, arg);
1121
+ break;
1122
+ }
1123
+ case TYPE_UCLASS: {
1124
+ const c = path2class(rUnique(arg));
1125
+ if (rbModSingletonP(c)) {
1126
+ throw new TypeError("singleton can't be loaded");
1127
+ }
1128
+ type = rByte(arg);
1129
+ if (c === Hash && (type === TYPE_HASH || type === TYPE_HASH_DEF)) {
1130
+ hashNewWithSize = () => new Hash().compareByIdentity();
1131
+ continue;
1132
+ }
1133
+ v = rObjectFor(arg, null, extmod, type);
1134
+ if (v === null || typeof v !== "object" || rbFloatTypeP(v) || tObjectP(v)) {
1135
+ throw new ArgumentError("dump format error (user class)");
1136
+ }
1137
+ const klass = rbObjClass(v);
1138
+ const proto = c.prototype;
1139
+ if (v instanceof Module || !(c === klass || proto instanceof klass)) {
1140
+ const tmp = objAllocByKlass(c, arg, null);
1141
+ if (v instanceof Module ||
1142
+ Array.isArray(v) !== tmp instanceof Array ||
1143
+ v instanceof Map !== tmp instanceof Map) {
1144
+ throw new ArgumentError("dump format error (user class)");
1145
+ }
1146
+ }
1147
+ Object.setPrototypeOf(v, proto);
1148
+ break;
1149
+ }
1150
+ case TYPE_NIL:
1151
+ v = null;
1152
+ v = rLeave(v, arg);
1153
+ break;
1154
+ case TYPE_TRUE:
1155
+ v = true;
1156
+ v = rLeave(v, arg);
1157
+ break;
1158
+ case TYPE_FALSE:
1159
+ v = false;
1160
+ v = rLeave(v, arg);
1161
+ break;
1162
+ case TYPE_FIXNUM: {
1163
+ const i = rLong(arg);
1164
+ v = i;
1165
+ v = rLeave(v, arg);
1166
+ break;
1167
+ }
1168
+ case TYPE_FLOAT: {
1169
+ let d;
1170
+ const ptr = rBytes(arg);
1171
+ if (ptr === "nan") {
1172
+ d = NaN;
1173
+ }
1174
+ else if (ptr === "inf") {
1175
+ d = Infinity;
1176
+ }
1177
+ else if (ptr === "-inf") {
1178
+ d = -Infinity;
1179
+ }
1180
+ else {
1181
+ d = Number.parseFloat(ptr);
1182
+ }
1183
+ v = rbDbl2num(d);
1184
+ v = rEntry(v, arg);
1185
+ v = rLeave(v, arg);
1186
+ break;
1187
+ }
1188
+ case TYPE_BIGNUM: {
1189
+ const sign = rByte(arg);
1190
+ const len = rLong(arg);
1191
+ let num = 0n;
1192
+ if (len <= 4) {
1193
+ for (let i = 0; i < len; i++) {
1194
+ num |= BigInt(rByte(arg)) << BigInt(i * 16);
1195
+ num |= BigInt(rByte(arg)) << BigInt(i * 16 + 8);
1196
+ }
1197
+ if (sign === 0x2d)
1198
+ num = -num;
1199
+ }
1200
+ else {
1201
+ const data = rBytes0(len * 2, arg);
1202
+ for (let i = data.length - 1; i >= 0; i--) {
1203
+ num = (num << 8n) | BigInt(data.charCodeAt(i));
1204
+ }
1205
+ if (sign === 0x2d)
1206
+ num = -num;
1207
+ }
1208
+ v = rbBigNorm(num);
1209
+ v = rEntry(v, arg);
1210
+ v = rLeave(v, arg);
1211
+ break;
1212
+ }
1213
+ case TYPE_STRING:
1214
+ v = rEntry(Uint8Array.from(rString(arg), (c) => c.charCodeAt(0)), arg);
1215
+ v = rLeave(v, arg);
1216
+ break;
1217
+ case TYPE_ARRAY: {
1218
+ let len = rLong(arg);
1219
+ const ary = [];
1220
+ v = rEntry(ary, arg);
1221
+ while (len--) {
1222
+ ary.push(rObject(arg));
1223
+ }
1224
+ v = rLeave(v, arg);
1225
+ break;
1226
+ }
1227
+ case TYPE_HASH:
1228
+ case TYPE_HASH_DEF: {
1229
+ let len = rLong(arg);
1230
+ const hash = hashNewWithSize();
1231
+ v = rEntry(hash, arg);
1232
+ while (len--) {
1233
+ const key = rObject(arg);
1234
+ const value = rObject(arg);
1235
+ hash.set(key, value);
1236
+ }
1237
+ if (type === TYPE_HASH_DEF) {
1238
+ hash.setDefault(rObject(arg));
1239
+ }
1240
+ v = rLeave(v, arg);
1241
+ break;
1242
+ }
1243
+ case TYPE_STRUCT: {
1244
+ const idx = rPrepare(arg);
1245
+ const klass = path2class(rUnique(arg));
1246
+ const len = rLong(arg);
1247
+ v = rbObjAlloc(klass);
1248
+ if (!isStruct(v)) {
1249
+ throw new TypeError(`class ${rbModToS(klass)} not a struct`);
1250
+ }
1251
+ const mem = v.members();
1252
+ if (mem.length !== len) {
1253
+ throw new TypeError(`struct ${rbModToS(klass)} not compatible (struct size differs)`);
1254
+ }
1255
+ v = rEntry0(v, idx, arg);
1256
+ const values = [];
1257
+ for (let i = 0; i < len; i++) {
1258
+ const n = mem[i];
1259
+ const slot = rSymbol(arg);
1260
+ if (n !== slot) {
1261
+ throw new TypeError(`struct ${rbModToS(klass)} not compatible (:${slot} for :${n})`);
1262
+ }
1263
+ values.push(rObject(arg));
1264
+ }
1265
+ rbStructInitialize(v, values);
1266
+ v = rLeave(v, arg);
1267
+ break;
1268
+ }
1269
+ case TYPE_USERDEF: {
1270
+ const name = rUnique(arg);
1271
+ const klass = path2class(name);
1272
+ if (!rbObjRespondTo(klass, "_load")) {
1273
+ throw new TypeError(`class ${name} needs to have method \`_load'`);
1274
+ }
1275
+ let data = rString(arg);
1276
+ if (ivp) {
1277
+ data = rIvar(new String(data), null, arg);
1278
+ ivp.value = false;
1279
+ }
1280
+ v = rbFSend(klass, "_load", data);
1281
+ v = rEntry(v, arg);
1282
+ const allocator = rbGetAllocFunc(klass);
1283
+ const compat = allocator === undefined ? undefined : compatAllocatorTbl.get(allocator);
1284
+ if (compat !== undefined) {
1285
+ v = compat.loader(klass, v);
1286
+ }
1287
+ break;
1288
+ }
1289
+ case TYPE_USRMARSHAL: {
1290
+ const name = rUnique(arg);
1291
+ const klass = path2class(name);
1292
+ const oldclass = { value: null };
1293
+ v = objAllocByKlass(klass, arg, oldclass);
1294
+ if (extmod !== null) {
1295
+ appendExtmod(v, extmod);
1296
+ }
1297
+ if (!rbObjRespondTo(v, "marshalLoad")) {
1298
+ throw new TypeError(`instance of ${name} needs to have method \`marshal_load'`);
1299
+ }
1300
+ v = rEntry(v, arg);
1301
+ const data = rObject(arg);
1302
+ rbFSend(v, "marshalLoad", data);
1303
+ v = rFixupCompat(v, arg);
1304
+ v = rCopyIvar(v, data);
1305
+ if (extmod !== null) {
1306
+ if (oldclass.value)
1307
+ appendExtmod(v, extmod);
1308
+ extmod.length = 0;
1309
+ }
1310
+ break;
1311
+ }
1312
+ case TYPE_OBJECT: {
1313
+ const idx = rPrepare(arg);
1314
+ v = objAllocByPath(rUnique(arg), arg);
1315
+ if (!tObjectP(v)) {
1316
+ throw new ArgumentError("dump format error");
1317
+ }
1318
+ v = rEntry0(v, idx, arg);
1319
+ rIvar(v, null, arg);
1320
+ v = rLeave(v, arg);
1321
+ break;
1322
+ }
1323
+ case TYPE_CLASS: {
1324
+ const str = { value: rBytes(arg) };
1325
+ if (ivp && ivp.value)
1326
+ ivp.value = rEncname(str, arg) > 0;
1327
+ v = path2class(str.value);
1328
+ prohibitIvar("class", str.value, ivp);
1329
+ v = rEntry(v, arg);
1330
+ v = rLeave(v, arg);
1331
+ break;
1332
+ }
1333
+ case TYPE_MODULE: {
1334
+ const str = { value: rBytes(arg) };
1335
+ if (ivp && ivp.value)
1336
+ ivp.value = rEncname(str, arg) > 0;
1337
+ v = mustBeModule(rbPathToClass(str.value), str.value);
1338
+ prohibitIvar("module", str.value, ivp);
1339
+ v = rEntry(v, arg);
1340
+ v = rLeave(v, arg);
1341
+ break;
1342
+ }
1343
+ case TYPE_SYMBOL:
1344
+ if (ivp) {
1345
+ v = rSymreal(arg, ivp.value);
1346
+ ivp.value = false;
1347
+ }
1348
+ else {
1349
+ v = rSymreal(arg, false);
1350
+ }
1351
+ v = `:${v}`;
1352
+ v = rLeave(v, arg);
1353
+ break;
1354
+ case TYPE_SYMLINK:
1355
+ v = `:${rSymlink(arg)}`;
1356
+ v = rLeave(v, arg);
1357
+ break;
1358
+ default:
1359
+ throw new ArgumentError(`dump format error(0x${type.toString(16)})`);
1360
+ }
1361
+ break;
1362
+ }
1363
+ if (v === undefined) {
1364
+ throw new ArgumentError("dump format error (bad link)");
1365
+ }
1366
+ return v;
1367
+ }
1368
+ /** `r_object` (`vendor/ruby/v3.3.11/marshal.c:2349`). */
1369
+ function rObject(arg) {
1370
+ return rObject0(arg, null, null);
1371
+ }
1372
+ /** `rb_marshal_load_with_proc` (`vendor/ruby/v3.3.11/marshal.c:2378`), for a String `port`. */
1373
+ function rbMarshalLoadWithProc(port) {
1374
+ let v;
1375
+ if (port instanceof Uint8Array) {
1376
+ v = "";
1377
+ for (const byte of port)
1378
+ v += String.fromCharCode(byte);
1379
+ }
1380
+ else {
1381
+ v = rbCheckStringType(port);
1382
+ }
1383
+ if (v === null) {
1384
+ throw new TypeError("instance of IO needed");
1385
+ }
1386
+ const arg = {
1387
+ src: v,
1388
+ offset: 0,
1389
+ symbols: [],
1390
+ data: new Map(),
1391
+ compatTbl: null,
1392
+ links: new Set(),
1393
+ };
1394
+ const major = rByte(arg);
1395
+ const minor = rByte(arg);
1396
+ if (major !== MARSHAL_MAJOR || minor > MARSHAL_MINOR) {
1397
+ throw new TypeError(`incompatible marshal file format (can't be read)\n\tformat version ${MARSHAL_MAJOR}.${MARSHAL_MINOR} required; ${major}.${minor} given`);
1398
+ }
1399
+ if (rtest(verbose()) && minor !== MARSHAL_MINOR) {
1400
+ warn(`incompatible marshal file format (can be read)\n\tformat version ${MARSHAL_MAJOR}.${MARSHAL_MINOR} required; ${major}.${minor} given`);
1401
+ }
1402
+ return rObject(arg);
1403
+ }
1404
+ /**
1405
+ * Ruby's `Marshal` (`vendor/ruby/v3.3.11/marshal.c:2555`), format 4.8. The
1406
+ * marshalled data is an ASCII-8BIT String, one character per byte.
1407
+ *
1408
+ * @noRailsEquivalent PERMANENT — Ruby core `Marshal`
1409
+ * (`vendor/ruby/v3.3.11/marshal.c:2555`), which Rails calls without defining.
1410
+ */
1411
+ export const Marshal = {
1412
+ /**
1413
+ * `Marshal.dump(obj, limit = -1)` (`marshal_dump`,
1414
+ * `vendor/ruby/v3.3.11/marshal.c:1207`, over `w_object`, `marshal.c:846`), for the types a
1415
+ * schema-cache dump holds
1416
+ * (`vendor/rails/v8.0.5.2/activerecord/lib/active_record/connection_adapters/schema_cache.rb:416-418`):
1417
+ * `nil`, `true`, `false`, Integer, Float, String, Symbol, Array, Hash and a
1418
+ * plain ivar object, plus Class and Module, and an object answering
1419
+ * `marshal_dump` (`TYPE_USRMARSHAL`, `marshal.c:910`). Any other value takes
1420
+ * the `T_DATA` arm's `TypeError`, and an object whose singleton class holds
1421
+ * a method or an ivar takes `w_extended`'s (`marshal.c:556`), which is what
1422
+ * `DebugHelper#debug` probes for
1423
+ * (`vendor/rails/v8.0.5.2/actionview/lib/action_view/helpers/debug_helper.rb:29`).
1424
+ *
1425
+ * @boundary: a JS string carries no encoding tag, so `encoding_name`
1426
+ * (`marshal.c:661`) answers UTF-8 for every String and `has_ivars`
1427
+ * (`marshal.c:713`) finds no ivars on a String, Array or Hash. `arg->data`
1428
+ * is an identity table, and a JS string, Float or Integer has no identity
1429
+ * apart from its value, so equal ones are one entry and the second is a
1430
+ * `TYPE_LINK`, as a deduplicated Ruby String's is; `-0.0` is keyed apart
1431
+ * from `0.0`, which a `Map` reads as one key. `ruby_dtoa(d, 0, …)`
1432
+ * (`marshal.c:444`) is the shortest round-tripping digit string, which
1433
+ * `toExponential()` also answers. A whole-valued `number` is an Integer
1434
+ * (`rbObjClassname`), so a Float `1.0` dumps as a Float only when boxed
1435
+ * (`rbDbl2num`). A JS string is UTF-16, and `TextEncoder` writes a lone
1436
+ * surrogate as U+FFFD where a Ruby String's bytes are written as they are.
1437
+ * `T_OBJECT` is a value `Object.prototype.toString` answers
1438
+ * `[object Object]` for that is not a plain hash, so a JS built-in with
1439
+ * internal slots, a Temporal value, or an instance of a class carrying
1440
+ * `Symbol.toStringTag` is `T_DATA` and takes its `TypeError`.
1441
+ *
1442
+ * `_dump` (`TYPE_USERDEF`, `marshal.c:918`) answers a String, or a boxed `String`
1443
+ * for an ASCII-8BIT one carrying ivars, as `Time#_dump` does.
1444
+ *
1445
+ * `markPlainObjects` gives each plain-object Hash the `@__trails_object` ivar,
1446
+ * so `Marshal.load` answers a plain object for it; Ruby's own dumps never set it.
1447
+ *
1448
+ * Not ported: the `anIO` argument; and the Regexp arm, which nothing calls.
1449
+ *
1450
+ * @noRailsEquivalent PERMANENT — Ruby core `Marshal.dump` (`vendor/ruby/v3.3.11/marshal.c:1207`).
1451
+ */
1452
+ dump(obj, limit = -1, markPlainObjects = false) {
1453
+ return rbMarshalDumpLimited(obj, limit, markPlainObjects);
1454
+ },
1455
+ /**
1456
+ * `Marshal.load(source)` (`marshal_load`, `vendor/ruby/v3.3.11/marshal.c:2434`,
1457
+ * over `r_object_for`, `marshal.c:1868`), for a String source holding what
1458
+ * {@link Marshal.dump} writes. `TYPE_USRMARSHAL` (`marshal.c:2217`) allocates the
1459
+ * class and sends it `marshal_load`.
1460
+ *
1461
+ * @boundary: a String with no `E` / `encoding` ivar loads as its bytes, one
1462
+ * character per byte, and one with the ivar is re-read through
1463
+ * `forceEncoding`. A Hash loads as ruby-compat's `Hash`, a whole-valued
1464
+ * Float loads boxed (`rbDbl2num`), and a Bignum goes through `rbBigNorm`.
1465
+ * `rb_obj_alloc` runs the class's allocator (`rbDefineAllocFunc`), else it
1466
+ * is `Object.create(klass.prototype)`, so no constructor runs. A class
1467
+ * with a compat entry ({@link rbMarshalDefineCompat}), as `Rational` has,
1468
+ * loads through it. `TYPE_UCLASS` re-classes an Array or Hash with `Object.setPrototypeOf`;
1469
+ * a JS string has no class to set, so a String subclass is a format error,
1470
+ * and no ivar table, so a String, Float or Bignum dumped with an ivar of its
1471
+ * own raises `FrozenError`. A class path resolves through `rbPathToClass`.
1472
+ *
1473
+ * Not ported: the `proc` and `freeze:` arguments and an IO source; and
1474
+ * `TYPE_DATA` and Regexp, which nothing calls. `TYPE_USERDEF` hands `_load` a boxed
1475
+ * `String` holding the String's ivars, which carries no encoding ivar. A Struct has
1476
+ * no `keyword_init`, so `TYPE_STRUCT` reads positional values only.
1477
+ *
1478
+ * @noRailsEquivalent PERMANENT — Ruby core `Marshal.load` (`vendor/ruby/v3.3.11/marshal.c:2434`).
1479
+ */
1480
+ load(source) {
1481
+ return rbMarshalLoadWithProc(source);
1482
+ },
1483
+ };
1484
+ rbMarshalDefineCompat(Rational, Rational.compatible, nuratDumper, nuratLoader);
1485
+ rbDefineAllocFunc(Range, (klass) => Object.create(klass.prototype));
1486
+ rbMarshalDefineCompat(Range, RObject, rangeDumper, rangeLoader);
1487
+ //# sourceMappingURL=marshal.js.map