@tellahq/rescript 10.1.0-alpha.1

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 (997) hide show
  1. package/CHANGELOG.md +1717 -0
  2. package/COPYING +674 -0
  3. package/COPYING.LESSER +165 -0
  4. package/CREDITS.md +59 -0
  5. package/LICENSE +24 -0
  6. package/README.md +114 -0
  7. package/bsc +22 -0
  8. package/bsrefmt +16 -0
  9. package/darwin/bsb_helper.exe +0 -0
  10. package/darwin/bsc.exe +0 -0
  11. package/darwin/ninja.COPYING +202 -0
  12. package/darwin/ninja.exe +0 -0
  13. package/darwin/refmt.exe +0 -0
  14. package/darwin/rescript.exe +0 -0
  15. package/darwinarm64/bsb_helper.exe +0 -0
  16. package/darwinarm64/bsc.exe +0 -0
  17. package/darwinarm64/ninja.COPYING +202 -0
  18. package/darwinarm64/ninja.exe +0 -0
  19. package/darwinarm64/refmt.exe +0 -0
  20. package/darwinarm64/rescript.exe +0 -0
  21. package/docs/docson/build-schema.json +557 -0
  22. package/freebsd/ninja.COPYING +202 -0
  23. package/jscomp/stubs/ext_basic_hash_stubs.c +216 -0
  24. package/lib/4.06.1/bsb_helper.ml +2436 -0
  25. package/lib/4.06.1/bsb_helper.mli +0 -0
  26. package/lib/4.06.1/refmt_main3.ml +115517 -0
  27. package/lib/4.06.1/refmt_main3.mli +1 -0
  28. package/lib/4.06.1/rescript.ml +15500 -0
  29. package/lib/4.06.1/rescript.mli +0 -0
  30. package/lib/4.06.1/whole_compiler.ml +306395 -0
  31. package/lib/4.06.1/whole_compiler.mli +0 -0
  32. package/lib/bstracing +270 -0
  33. package/lib/es6/arg.js +717 -0
  34. package/lib/es6/array.js +511 -0
  35. package/lib/es6/arrayLabels.js +511 -0
  36. package/lib/es6/belt.js +57 -0
  37. package/lib/es6/belt_Array.js +764 -0
  38. package/lib/es6/belt_Float.js +16 -0
  39. package/lib/es6/belt_HashMap.js +280 -0
  40. package/lib/es6/belt_HashMapInt.js +264 -0
  41. package/lib/es6/belt_HashMapString.js +264 -0
  42. package/lib/es6/belt_HashSet.js +222 -0
  43. package/lib/es6/belt_HashSetInt.js +207 -0
  44. package/lib/es6/belt_HashSetString.js +207 -0
  45. package/lib/es6/belt_Id.js +71 -0
  46. package/lib/es6/belt_Int.js +16 -0
  47. package/lib/es6/belt_List.js +1512 -0
  48. package/lib/es6/belt_Map.js +376 -0
  49. package/lib/es6/belt_MapDict.js +417 -0
  50. package/lib/es6/belt_MapInt.js +307 -0
  51. package/lib/es6/belt_MapString.js +307 -0
  52. package/lib/es6/belt_MutableMap.js +395 -0
  53. package/lib/es6/belt_MutableMapInt.js +362 -0
  54. package/lib/es6/belt_MutableMapString.js +362 -0
  55. package/lib/es6/belt_MutableQueue.js +299 -0
  56. package/lib/es6/belt_MutableSet.js +538 -0
  57. package/lib/es6/belt_MutableSetInt.js +501 -0
  58. package/lib/es6/belt_MutableSetString.js +501 -0
  59. package/lib/es6/belt_MutableStack.js +137 -0
  60. package/lib/es6/belt_Option.js +151 -0
  61. package/lib/es6/belt_Range.js +109 -0
  62. package/lib/es6/belt_Result.js +136 -0
  63. package/lib/es6/belt_Set.js +314 -0
  64. package/lib/es6/belt_SetDict.js +362 -0
  65. package/lib/es6/belt_SetInt.js +359 -0
  66. package/lib/es6/belt_SetString.js +359 -0
  67. package/lib/es6/belt_SortArray.js +427 -0
  68. package/lib/es6/belt_SortArrayInt.js +374 -0
  69. package/lib/es6/belt_SortArrayString.js +374 -0
  70. package/lib/es6/belt_internalAVLset.js +940 -0
  71. package/lib/es6/belt_internalAVLtree.js +1146 -0
  72. package/lib/es6/belt_internalBuckets.js +287 -0
  73. package/lib/es6/belt_internalBucketsType.js +49 -0
  74. package/lib/es6/belt_internalMapInt.js +365 -0
  75. package/lib/es6/belt_internalMapString.js +365 -0
  76. package/lib/es6/belt_internalSetBuckets.js +191 -0
  77. package/lib/es6/belt_internalSetInt.js +209 -0
  78. package/lib/es6/belt_internalSetString.js +209 -0
  79. package/lib/es6/buffer.js +477 -0
  80. package/lib/es6/bytes.js +704 -0
  81. package/lib/es6/bytesLabels.js +704 -0
  82. package/lib/es6/callback.js +16 -0
  83. package/lib/es6/caml.js +196 -0
  84. package/lib/es6/caml_array.js +122 -0
  85. package/lib/es6/caml_array_extern.js +1 -0
  86. package/lib/es6/caml_bytes.js +122 -0
  87. package/lib/es6/caml_exceptions.js +31 -0
  88. package/lib/es6/caml_external_polyfill.js +32 -0
  89. package/lib/es6/caml_float.js +129 -0
  90. package/lib/es6/caml_float_extern.js +1 -0
  91. package/lib/es6/caml_format.js +818 -0
  92. package/lib/es6/caml_hash.js +101 -0
  93. package/lib/es6/caml_hash_primitive.js +51 -0
  94. package/lib/es6/caml_int32.js +28 -0
  95. package/lib/es6/caml_int64.js +606 -0
  96. package/lib/es6/caml_int64_extern.js +1 -0
  97. package/lib/es6/caml_js_exceptions.js +31 -0
  98. package/lib/es6/caml_lexer.js +258 -0
  99. package/lib/es6/caml_md5.js +168 -0
  100. package/lib/es6/caml_module.js +117 -0
  101. package/lib/es6/caml_nativeint_extern.js +1 -0
  102. package/lib/es6/caml_obj.js +413 -0
  103. package/lib/es6/caml_option.js +86 -0
  104. package/lib/es6/caml_parser.js +303 -0
  105. package/lib/es6/caml_splice_call.js +52 -0
  106. package/lib/es6/caml_string.js +23 -0
  107. package/lib/es6/caml_string_extern.js +1 -0
  108. package/lib/es6/caml_sys.js +99 -0
  109. package/lib/es6/caml_undefined_extern.js +1 -0
  110. package/lib/es6/camlinternalLazy.js +59 -0
  111. package/lib/es6/camlinternalMod.js +1 -0
  112. package/lib/es6/char.js +126 -0
  113. package/lib/es6/complex.js +176 -0
  114. package/lib/es6/curry.js +526 -0
  115. package/lib/es6/digest.js +118 -0
  116. package/lib/es6/dom.js +12 -0
  117. package/lib/es6/dom_storage.js +27 -0
  118. package/lib/es6/dom_storage2.js +1 -0
  119. package/lib/es6/filename.js +496 -0
  120. package/lib/es6/genlex.js +666 -0
  121. package/lib/es6/hashtbl.js +1115 -0
  122. package/lib/es6/hashtblLabels.js +170 -0
  123. package/lib/es6/int32.js +75 -0
  124. package/lib/es6/int64.js +70 -0
  125. package/lib/es6/js.js +111 -0
  126. package/lib/es6/js_OO.js +15 -0
  127. package/lib/es6/js_array.js +223 -0
  128. package/lib/es6/js_array2.js +1 -0
  129. package/lib/es6/js_bigint.js +1 -0
  130. package/lib/es6/js_cast.js +1 -0
  131. package/lib/es6/js_console.js +1 -0
  132. package/lib/es6/js_date.js +1 -0
  133. package/lib/es6/js_dict.js +85 -0
  134. package/lib/es6/js_exn.js +44 -0
  135. package/lib/es6/js_float.js +1 -0
  136. package/lib/es6/js_global.js +1 -0
  137. package/lib/es6/js_int.js +17 -0
  138. package/lib/es6/js_json.js +172 -0
  139. package/lib/es6/js_list.js +333 -0
  140. package/lib/es6/js_map.js +1 -0
  141. package/lib/es6/js_mapperRt.js +54 -0
  142. package/lib/es6/js_math.js +50 -0
  143. package/lib/es6/js_null.js +49 -0
  144. package/lib/es6/js_null_undefined.js +35 -0
  145. package/lib/es6/js_obj.js +1 -0
  146. package/lib/es6/js_option.js +104 -0
  147. package/lib/es6/js_promise.js +17 -0
  148. package/lib/es6/js_re.js +1 -0
  149. package/lib/es6/js_result.js +1 -0
  150. package/lib/es6/js_set.js +1 -0
  151. package/lib/es6/js_string.js +199 -0
  152. package/lib/es6/js_string2.js +1 -0
  153. package/lib/es6/js_typed_array.js +1733 -0
  154. package/lib/es6/js_typed_array2.js +39 -0
  155. package/lib/es6/js_types.js +77 -0
  156. package/lib/es6/js_undefined.js +52 -0
  157. package/lib/es6/js_vector.js +134 -0
  158. package/lib/es6/js_weakmap.js +1 -0
  159. package/lib/es6/js_weakset.js +1 -0
  160. package/lib/es6/jsx.js +1 -0
  161. package/lib/es6/jsxDOM.js +1 -0
  162. package/lib/es6/jsxDOMStyle.js +1 -0
  163. package/lib/es6/jsxEvent.js +59 -0
  164. package/lib/es6/lazy.js +44 -0
  165. package/lib/es6/lexing.js +217 -0
  166. package/lib/es6/list.js +1713 -0
  167. package/lib/es6/listLabels.js +1713 -0
  168. package/lib/es6/map.js +936 -0
  169. package/lib/es6/mapLabels.js +951 -0
  170. package/lib/es6/moreLabels.js +1931 -0
  171. package/lib/es6/node.js +39 -0
  172. package/lib/es6/node_buffer.js +1 -0
  173. package/lib/es6/node_child_process.js +1 -0
  174. package/lib/es6/node_fs.js +9 -0
  175. package/lib/es6/node_module.js +1 -0
  176. package/lib/es6/node_path.js +1 -0
  177. package/lib/es6/node_process.js +18 -0
  178. package/lib/es6/obj.js +11 -0
  179. package/lib/es6/package.json +1 -0
  180. package/lib/es6/parsing.js +237 -0
  181. package/lib/es6/pervasives.js +250 -0
  182. package/lib/es6/printexc.js +102 -0
  183. package/lib/es6/queue.js +181 -0
  184. package/lib/es6/random.js +280 -0
  185. package/lib/es6/set.js +955 -0
  186. package/lib/es6/setLabels.js +988 -0
  187. package/lib/es6/sort.js +168 -0
  188. package/lib/es6/stack.js +88 -0
  189. package/lib/es6/stdLabels.js +18 -0
  190. package/lib/es6/stream.js +496 -0
  191. package/lib/es6/string.js +337 -0
  192. package/lib/es6/stringLabels.js +337 -0
  193. package/lib/es6/sys.js +182 -0
  194. package/lib/es6/uchar.js +133 -0
  195. package/lib/js/arg.js +715 -0
  196. package/lib/js/array.js +509 -0
  197. package/lib/js/arrayLabels.js +509 -0
  198. package/lib/js/belt.js +55 -0
  199. package/lib/js/belt_Array.js +762 -0
  200. package/lib/js/belt_Float.js +14 -0
  201. package/lib/js/belt_HashMap.js +278 -0
  202. package/lib/js/belt_HashMapInt.js +262 -0
  203. package/lib/js/belt_HashMapString.js +262 -0
  204. package/lib/js/belt_HashSet.js +220 -0
  205. package/lib/js/belt_HashSetInt.js +205 -0
  206. package/lib/js/belt_HashSetString.js +205 -0
  207. package/lib/js/belt_Id.js +69 -0
  208. package/lib/js/belt_Int.js +14 -0
  209. package/lib/js/belt_List.js +1510 -0
  210. package/lib/js/belt_Map.js +374 -0
  211. package/lib/js/belt_MapDict.js +415 -0
  212. package/lib/js/belt_MapInt.js +305 -0
  213. package/lib/js/belt_MapString.js +305 -0
  214. package/lib/js/belt_MutableMap.js +393 -0
  215. package/lib/js/belt_MutableMapInt.js +360 -0
  216. package/lib/js/belt_MutableMapString.js +360 -0
  217. package/lib/js/belt_MutableQueue.js +297 -0
  218. package/lib/js/belt_MutableSet.js +536 -0
  219. package/lib/js/belt_MutableSetInt.js +499 -0
  220. package/lib/js/belt_MutableSetString.js +499 -0
  221. package/lib/js/belt_MutableStack.js +135 -0
  222. package/lib/js/belt_Option.js +149 -0
  223. package/lib/js/belt_Range.js +107 -0
  224. package/lib/js/belt_Result.js +134 -0
  225. package/lib/js/belt_Set.js +312 -0
  226. package/lib/js/belt_SetDict.js +360 -0
  227. package/lib/js/belt_SetInt.js +357 -0
  228. package/lib/js/belt_SetString.js +357 -0
  229. package/lib/js/belt_SortArray.js +425 -0
  230. package/lib/js/belt_SortArrayInt.js +372 -0
  231. package/lib/js/belt_SortArrayString.js +372 -0
  232. package/lib/js/belt_internalAVLset.js +938 -0
  233. package/lib/js/belt_internalAVLtree.js +1144 -0
  234. package/lib/js/belt_internalBuckets.js +285 -0
  235. package/lib/js/belt_internalBucketsType.js +47 -0
  236. package/lib/js/belt_internalMapInt.js +363 -0
  237. package/lib/js/belt_internalMapString.js +363 -0
  238. package/lib/js/belt_internalSetBuckets.js +189 -0
  239. package/lib/js/belt_internalSetInt.js +207 -0
  240. package/lib/js/belt_internalSetString.js +207 -0
  241. package/lib/js/buffer.js +475 -0
  242. package/lib/js/bytes.js +702 -0
  243. package/lib/js/bytesLabels.js +702 -0
  244. package/lib/js/callback.js +14 -0
  245. package/lib/js/caml.js +194 -0
  246. package/lib/js/caml_array.js +120 -0
  247. package/lib/js/caml_array_extern.js +1 -0
  248. package/lib/js/caml_bytes.js +120 -0
  249. package/lib/js/caml_exceptions.js +29 -0
  250. package/lib/js/caml_external_polyfill.js +30 -0
  251. package/lib/js/caml_float.js +127 -0
  252. package/lib/js/caml_float_extern.js +1 -0
  253. package/lib/js/caml_format.js +816 -0
  254. package/lib/js/caml_hash.js +99 -0
  255. package/lib/js/caml_hash_primitive.js +49 -0
  256. package/lib/js/caml_int32.js +26 -0
  257. package/lib/js/caml_int64.js +604 -0
  258. package/lib/js/caml_int64_extern.js +1 -0
  259. package/lib/js/caml_js_exceptions.js +29 -0
  260. package/lib/js/caml_lexer.js +256 -0
  261. package/lib/js/caml_md5.js +166 -0
  262. package/lib/js/caml_module.js +115 -0
  263. package/lib/js/caml_nativeint_extern.js +1 -0
  264. package/lib/js/caml_obj.js +411 -0
  265. package/lib/js/caml_option.js +84 -0
  266. package/lib/js/caml_parser.js +301 -0
  267. package/lib/js/caml_splice_call.js +50 -0
  268. package/lib/js/caml_string.js +21 -0
  269. package/lib/js/caml_string_extern.js +1 -0
  270. package/lib/js/caml_sys.js +97 -0
  271. package/lib/js/caml_undefined_extern.js +1 -0
  272. package/lib/js/camlinternalLazy.js +57 -0
  273. package/lib/js/camlinternalMod.js +1 -0
  274. package/lib/js/char.js +124 -0
  275. package/lib/js/complex.js +174 -0
  276. package/lib/js/curry.js +524 -0
  277. package/lib/js/digest.js +116 -0
  278. package/lib/js/dom.js +10 -0
  279. package/lib/js/dom_storage.js +25 -0
  280. package/lib/js/dom_storage2.js +1 -0
  281. package/lib/js/filename.js +494 -0
  282. package/lib/js/genlex.js +664 -0
  283. package/lib/js/hashtbl.js +1113 -0
  284. package/lib/js/hashtblLabels.js +168 -0
  285. package/lib/js/int32.js +73 -0
  286. package/lib/js/int64.js +68 -0
  287. package/lib/js/js.js +109 -0
  288. package/lib/js/js_OO.js +13 -0
  289. package/lib/js/js_array.js +221 -0
  290. package/lib/js/js_array2.js +1 -0
  291. package/lib/js/js_bigint.js +1 -0
  292. package/lib/js/js_cast.js +1 -0
  293. package/lib/js/js_console.js +1 -0
  294. package/lib/js/js_date.js +1 -0
  295. package/lib/js/js_dict.js +83 -0
  296. package/lib/js/js_exn.js +42 -0
  297. package/lib/js/js_float.js +1 -0
  298. package/lib/js/js_global.js +1 -0
  299. package/lib/js/js_int.js +15 -0
  300. package/lib/js/js_json.js +170 -0
  301. package/lib/js/js_list.js +331 -0
  302. package/lib/js/js_map.js +1 -0
  303. package/lib/js/js_mapperRt.js +52 -0
  304. package/lib/js/js_math.js +48 -0
  305. package/lib/js/js_null.js +47 -0
  306. package/lib/js/js_null_undefined.js +33 -0
  307. package/lib/js/js_obj.js +1 -0
  308. package/lib/js/js_option.js +103 -0
  309. package/lib/js/js_promise.js +15 -0
  310. package/lib/js/js_re.js +1 -0
  311. package/lib/js/js_result.js +1 -0
  312. package/lib/js/js_set.js +1 -0
  313. package/lib/js/js_string.js +197 -0
  314. package/lib/js/js_string2.js +1 -0
  315. package/lib/js/js_typed_array.js +1731 -0
  316. package/lib/js/js_typed_array2.js +37 -0
  317. package/lib/js/js_types.js +75 -0
  318. package/lib/js/js_undefined.js +50 -0
  319. package/lib/js/js_vector.js +132 -0
  320. package/lib/js/js_weakmap.js +1 -0
  321. package/lib/js/js_weakset.js +1 -0
  322. package/lib/js/jsx.js +1 -0
  323. package/lib/js/jsxDOM.js +1 -0
  324. package/lib/js/jsxDOMStyle.js +1 -0
  325. package/lib/js/jsxEvent.js +57 -0
  326. package/lib/js/lazy.js +42 -0
  327. package/lib/js/lexing.js +215 -0
  328. package/lib/js/list.js +1711 -0
  329. package/lib/js/listLabels.js +1711 -0
  330. package/lib/js/map.js +934 -0
  331. package/lib/js/mapLabels.js +949 -0
  332. package/lib/js/moreLabels.js +1929 -0
  333. package/lib/js/node.js +37 -0
  334. package/lib/js/node_buffer.js +1 -0
  335. package/lib/js/node_child_process.js +1 -0
  336. package/lib/js/node_fs.js +7 -0
  337. package/lib/js/node_module.js +1 -0
  338. package/lib/js/node_path.js +1 -0
  339. package/lib/js/node_process.js +16 -0
  340. package/lib/js/obj.js +9 -0
  341. package/lib/js/parsing.js +235 -0
  342. package/lib/js/pervasives.js +248 -0
  343. package/lib/js/printexc.js +100 -0
  344. package/lib/js/queue.js +179 -0
  345. package/lib/js/random.js +278 -0
  346. package/lib/js/set.js +953 -0
  347. package/lib/js/setLabels.js +986 -0
  348. package/lib/js/sort.js +166 -0
  349. package/lib/js/stack.js +86 -0
  350. package/lib/js/stdLabels.js +16 -0
  351. package/lib/js/stream.js +494 -0
  352. package/lib/js/string.js +335 -0
  353. package/lib/js/stringLabels.js +335 -0
  354. package/lib/js/sys.js +180 -0
  355. package/lib/js/uchar.js +131 -0
  356. package/lib/minisocket.js +93 -0
  357. package/lib/ocaml/arg.cmi +0 -0
  358. package/lib/ocaml/arg.cmt +0 -0
  359. package/lib/ocaml/arg.cmti +0 -0
  360. package/lib/ocaml/arg.ml +359 -0
  361. package/lib/ocaml/arg.mli +185 -0
  362. package/lib/ocaml/array.cmi +0 -0
  363. package/lib/ocaml/array.cmt +0 -0
  364. package/lib/ocaml/array.cmti +0 -0
  365. package/lib/ocaml/array.ml +307 -0
  366. package/lib/ocaml/array.mli +275 -0
  367. package/lib/ocaml/arrayLabels.cmi +0 -0
  368. package/lib/ocaml/arrayLabels.cmt +0 -0
  369. package/lib/ocaml/arrayLabels.cmti +0 -0
  370. package/lib/ocaml/arrayLabels.ml +307 -0
  371. package/lib/ocaml/arrayLabels.mli +276 -0
  372. package/lib/ocaml/belt.cmi +0 -0
  373. package/lib/ocaml/belt.cmt +0 -0
  374. package/lib/ocaml/belt.ml +352 -0
  375. package/lib/ocaml/belt_Array.cmi +0 -0
  376. package/lib/ocaml/belt_Array.cmt +0 -0
  377. package/lib/ocaml/belt_Array.cmti +0 -0
  378. package/lib/ocaml/belt_Array.ml +525 -0
  379. package/lib/ocaml/belt_Array.mli +707 -0
  380. package/lib/ocaml/belt_Float.cmi +0 -0
  381. package/lib/ocaml/belt_Float.cmt +0 -0
  382. package/lib/ocaml/belt_Float.cmti +0 -0
  383. package/lib/ocaml/belt_Float.ml +50 -0
  384. package/lib/ocaml/belt_Float.mli +106 -0
  385. package/lib/ocaml/belt_HashMap.cmi +0 -0
  386. package/lib/ocaml/belt_HashMap.cmt +0 -0
  387. package/lib/ocaml/belt_HashMap.cmti +0 -0
  388. package/lib/ocaml/belt_HashMap.ml +226 -0
  389. package/lib/ocaml/belt_HashMap.mli +436 -0
  390. package/lib/ocaml/belt_HashMapInt.cmi +0 -0
  391. package/lib/ocaml/belt_HashMapInt.cmt +0 -0
  392. package/lib/ocaml/belt_HashMapInt.cmti +0 -0
  393. package/lib/ocaml/belt_HashMapInt.ml +206 -0
  394. package/lib/ocaml/belt_HashMapInt.mli +50 -0
  395. package/lib/ocaml/belt_HashMapString.cmi +0 -0
  396. package/lib/ocaml/belt_HashMapString.cmt +0 -0
  397. package/lib/ocaml/belt_HashMapString.cmti +0 -0
  398. package/lib/ocaml/belt_HashMapString.ml +206 -0
  399. package/lib/ocaml/belt_HashMapString.mli +50 -0
  400. package/lib/ocaml/belt_HashSet.cmi +0 -0
  401. package/lib/ocaml/belt_HashSet.cmt +0 -0
  402. package/lib/ocaml/belt_HashSet.cmti +0 -0
  403. package/lib/ocaml/belt_HashSet.ml +196 -0
  404. package/lib/ocaml/belt_HashSet.mli +125 -0
  405. package/lib/ocaml/belt_HashSetInt.cmi +0 -0
  406. package/lib/ocaml/belt_HashSetInt.cmt +0 -0
  407. package/lib/ocaml/belt_HashSetInt.cmti +0 -0
  408. package/lib/ocaml/belt_HashSetInt.ml +155 -0
  409. package/lib/ocaml/belt_HashSetInt.mli +74 -0
  410. package/lib/ocaml/belt_HashSetString.cmi +0 -0
  411. package/lib/ocaml/belt_HashSetString.cmt +0 -0
  412. package/lib/ocaml/belt_HashSetString.cmti +0 -0
  413. package/lib/ocaml/belt_HashSetString.ml +156 -0
  414. package/lib/ocaml/belt_HashSetString.mli +74 -0
  415. package/lib/ocaml/belt_Id.cmi +0 -0
  416. package/lib/ocaml/belt_Id.cmt +0 -0
  417. package/lib/ocaml/belt_Id.cmti +0 -0
  418. package/lib/ocaml/belt_Id.ml +133 -0
  419. package/lib/ocaml/belt_Id.mli +171 -0
  420. package/lib/ocaml/belt_Int.cmi +0 -0
  421. package/lib/ocaml/belt_Int.cmt +0 -0
  422. package/lib/ocaml/belt_Int.cmti +0 -0
  423. package/lib/ocaml/belt_Int.ml +50 -0
  424. package/lib/ocaml/belt_Int.mli +103 -0
  425. package/lib/ocaml/belt_List.cmi +0 -0
  426. package/lib/ocaml/belt_List.cmt +0 -0
  427. package/lib/ocaml/belt_List.cmti +0 -0
  428. package/lib/ocaml/belt_List.ml +803 -0
  429. package/lib/ocaml/belt_List.mli +844 -0
  430. package/lib/ocaml/belt_Map.cmi +0 -0
  431. package/lib/ocaml/belt_Map.cmt +0 -0
  432. package/lib/ocaml/belt_Map.cmti +0 -0
  433. package/lib/ocaml/belt_Map.ml +170 -0
  434. package/lib/ocaml/belt_Map.mli +496 -0
  435. package/lib/ocaml/belt_MapDict.cmi +0 -0
  436. package/lib/ocaml/belt_MapDict.cmt +0 -0
  437. package/lib/ocaml/belt_MapDict.cmti +0 -0
  438. package/lib/ocaml/belt_MapDict.ml +278 -0
  439. package/lib/ocaml/belt_MapDict.mli +268 -0
  440. package/lib/ocaml/belt_MapInt.cmi +0 -0
  441. package/lib/ocaml/belt_MapInt.cmt +0 -0
  442. package/lib/ocaml/belt_MapInt.cmti +0 -0
  443. package/lib/ocaml/belt_MapInt.ml +169 -0
  444. package/lib/ocaml/belt_MapInt.mli +187 -0
  445. package/lib/ocaml/belt_MapString.cmi +0 -0
  446. package/lib/ocaml/belt_MapString.cmt +0 -0
  447. package/lib/ocaml/belt_MapString.cmti +0 -0
  448. package/lib/ocaml/belt_MapString.ml +169 -0
  449. package/lib/ocaml/belt_MapString.mli +187 -0
  450. package/lib/ocaml/belt_MutableMap.cmi +0 -0
  451. package/lib/ocaml/belt_MutableMap.cmt +0 -0
  452. package/lib/ocaml/belt_MutableMap.cmti +0 -0
  453. package/lib/ocaml/belt_MutableMap.ml +241 -0
  454. package/lib/ocaml/belt_MutableMap.mli +145 -0
  455. package/lib/ocaml/belt_MutableMapInt.cmi +0 -0
  456. package/lib/ocaml/belt_MutableMapInt.cmt +0 -0
  457. package/lib/ocaml/belt_MutableMapInt.cmti +0 -0
  458. package/lib/ocaml/belt_MutableMapInt.ml +172 -0
  459. package/lib/ocaml/belt_MutableMapInt.mli +135 -0
  460. package/lib/ocaml/belt_MutableMapString.cmi +0 -0
  461. package/lib/ocaml/belt_MutableMapString.cmt +0 -0
  462. package/lib/ocaml/belt_MutableMapString.cmti +0 -0
  463. package/lib/ocaml/belt_MutableMapString.ml +172 -0
  464. package/lib/ocaml/belt_MutableMapString.mli +135 -0
  465. package/lib/ocaml/belt_MutableQueue.cmi +0 -0
  466. package/lib/ocaml/belt_MutableQueue.cmt +0 -0
  467. package/lib/ocaml/belt_MutableQueue.cmti +0 -0
  468. package/lib/ocaml/belt_MutableQueue.ml +222 -0
  469. package/lib/ocaml/belt_MutableQueue.mli +116 -0
  470. package/lib/ocaml/belt_MutableSet.cmi +0 -0
  471. package/lib/ocaml/belt_MutableSet.cmt +0 -0
  472. package/lib/ocaml/belt_MutableSet.cmti +0 -0
  473. package/lib/ocaml/belt_MutableSet.ml +371 -0
  474. package/lib/ocaml/belt_MutableSet.mli +617 -0
  475. package/lib/ocaml/belt_MutableSetInt.cmi +0 -0
  476. package/lib/ocaml/belt_MutableSetInt.cmt +0 -0
  477. package/lib/ocaml/belt_MutableSetInt.cmti +0 -0
  478. package/lib/ocaml/belt_MutableSetInt.ml +342 -0
  479. package/lib/ocaml/belt_MutableSetInt.mli +124 -0
  480. package/lib/ocaml/belt_MutableSetString.cmi +0 -0
  481. package/lib/ocaml/belt_MutableSetString.cmt +0 -0
  482. package/lib/ocaml/belt_MutableSetString.cmti +0 -0
  483. package/lib/ocaml/belt_MutableSetString.ml +342 -0
  484. package/lib/ocaml/belt_MutableSetString.mli +124 -0
  485. package/lib/ocaml/belt_MutableStack.cmi +0 -0
  486. package/lib/ocaml/belt_MutableStack.cmt +0 -0
  487. package/lib/ocaml/belt_MutableStack.cmti +0 -0
  488. package/lib/ocaml/belt_MutableStack.ml +106 -0
  489. package/lib/ocaml/belt_MutableStack.mli +63 -0
  490. package/lib/ocaml/belt_Option.cmi +0 -0
  491. package/lib/ocaml/belt_Option.cmt +0 -0
  492. package/lib/ocaml/belt_Option.cmti +0 -0
  493. package/lib/ocaml/belt_Option.ml +93 -0
  494. package/lib/ocaml/belt_Option.mli +270 -0
  495. package/lib/ocaml/belt_Range.cmi +0 -0
  496. package/lib/ocaml/belt_Range.cmt +0 -0
  497. package/lib/ocaml/belt_Range.cmti +0 -0
  498. package/lib/ocaml/belt_Range.ml +76 -0
  499. package/lib/ocaml/belt_Range.mli +114 -0
  500. package/lib/ocaml/belt_Result.cmi +0 -0
  501. package/lib/ocaml/belt_Result.cmt +0 -0
  502. package/lib/ocaml/belt_Result.cmti +0 -0
  503. package/lib/ocaml/belt_Result.ml +75 -0
  504. package/lib/ocaml/belt_Result.mli +205 -0
  505. package/lib/ocaml/belt_Set.cmi +0 -0
  506. package/lib/ocaml/belt_Set.cmt +0 -0
  507. package/lib/ocaml/belt_Set.cmti +0 -0
  508. package/lib/ocaml/belt_Set.cppo.ml +205 -0
  509. package/lib/ocaml/belt_Set.cppo.mli +153 -0
  510. package/lib/ocaml/belt_Set.ml +164 -0
  511. package/lib/ocaml/belt_Set.mli +523 -0
  512. package/lib/ocaml/belt_SetDict.cmi +0 -0
  513. package/lib/ocaml/belt_SetDict.cmt +0 -0
  514. package/lib/ocaml/belt_SetDict.cmti +0 -0
  515. package/lib/ocaml/belt_SetDict.ml +237 -0
  516. package/lib/ocaml/belt_SetDict.mli +567 -0
  517. package/lib/ocaml/belt_SetInt.cmi +0 -0
  518. package/lib/ocaml/belt_SetInt.cmt +0 -0
  519. package/lib/ocaml/belt_SetInt.cmti +0 -0
  520. package/lib/ocaml/belt_SetInt.ml +201 -0
  521. package/lib/ocaml/belt_SetInt.mli +151 -0
  522. package/lib/ocaml/belt_SetString.cmi +0 -0
  523. package/lib/ocaml/belt_SetString.cmt +0 -0
  524. package/lib/ocaml/belt_SetString.cmti +0 -0
  525. package/lib/ocaml/belt_SetString.ml +201 -0
  526. package/lib/ocaml/belt_SetString.mli +151 -0
  527. package/lib/ocaml/belt_SortArray.cmi +0 -0
  528. package/lib/ocaml/belt_SortArray.cmt +0 -0
  529. package/lib/ocaml/belt_SortArray.cmti +0 -0
  530. package/lib/ocaml/belt_SortArray.ml +322 -0
  531. package/lib/ocaml/belt_SortArray.mli +146 -0
  532. package/lib/ocaml/belt_SortArrayInt.cmi +0 -0
  533. package/lib/ocaml/belt_SortArrayInt.cmt +0 -0
  534. package/lib/ocaml/belt_SortArrayInt.cmti +0 -0
  535. package/lib/ocaml/belt_SortArrayInt.ml +263 -0
  536. package/lib/ocaml/belt_SortArrayInt.mli +93 -0
  537. package/lib/ocaml/belt_SortArrayString.cmi +0 -0
  538. package/lib/ocaml/belt_SortArrayString.cmt +0 -0
  539. package/lib/ocaml/belt_SortArrayString.cmti +0 -0
  540. package/lib/ocaml/belt_SortArrayString.ml +263 -0
  541. package/lib/ocaml/belt_SortArrayString.mli +93 -0
  542. package/lib/ocaml/belt_internalAVLset.cmt +0 -0
  543. package/lib/ocaml/belt_internalAVLset.cmti +0 -0
  544. package/lib/ocaml/belt_internalAVLset.ml +665 -0
  545. package/lib/ocaml/belt_internalAVLset.mli +124 -0
  546. package/lib/ocaml/belt_internalAVLtree.cmt +0 -0
  547. package/lib/ocaml/belt_internalAVLtree.cmti +0 -0
  548. package/lib/ocaml/belt_internalAVLtree.ml +762 -0
  549. package/lib/ocaml/belt_internalAVLtree.mli +215 -0
  550. package/lib/ocaml/belt_internalBuckets.cmt +0 -0
  551. package/lib/ocaml/belt_internalBuckets.cmti +0 -0
  552. package/lib/ocaml/belt_internalBuckets.ml +218 -0
  553. package/lib/ocaml/belt_internalBuckets.mli +57 -0
  554. package/lib/ocaml/belt_internalBucketsType.cmt +0 -0
  555. package/lib/ocaml/belt_internalBucketsType.cmti +0 -0
  556. package/lib/ocaml/belt_internalBucketsType.ml +59 -0
  557. package/lib/ocaml/belt_internalBucketsType.mli +46 -0
  558. package/lib/ocaml/belt_internalMapInt.cmt +0 -0
  559. package/lib/ocaml/belt_internalMapInt.ml +227 -0
  560. package/lib/ocaml/belt_internalMapString.cmt +0 -0
  561. package/lib/ocaml/belt_internalMapString.ml +227 -0
  562. package/lib/ocaml/belt_internalSetBuckets.cmt +0 -0
  563. package/lib/ocaml/belt_internalSetBuckets.cmti +0 -0
  564. package/lib/ocaml/belt_internalSetBuckets.ml +157 -0
  565. package/lib/ocaml/belt_internalSetBuckets.mli +47 -0
  566. package/lib/ocaml/belt_internalSetInt.cmt +0 -0
  567. package/lib/ocaml/belt_internalSetInt.ml +129 -0
  568. package/lib/ocaml/belt_internalSetString.cmt +0 -0
  569. package/lib/ocaml/belt_internalSetString.ml +129 -0
  570. package/lib/ocaml/belt_internals.cmti +0 -0
  571. package/lib/ocaml/belt_internals.mli +79 -0
  572. package/lib/ocaml/buffer.cmi +0 -0
  573. package/lib/ocaml/buffer.cmt +0 -0
  574. package/lib/ocaml/buffer.cmti +0 -0
  575. package/lib/ocaml/buffer.ml +250 -0
  576. package/lib/ocaml/buffer.mli +149 -0
  577. package/lib/ocaml/bytes.cmi +0 -0
  578. package/lib/ocaml/bytes.cmt +0 -0
  579. package/lib/ocaml/bytes.cmti +0 -0
  580. package/lib/ocaml/bytes.ml +431 -0
  581. package/lib/ocaml/bytes.mli +430 -0
  582. package/lib/ocaml/bytesLabels.cmi +0 -0
  583. package/lib/ocaml/bytesLabels.cmt +0 -0
  584. package/lib/ocaml/bytesLabels.cmti +0 -0
  585. package/lib/ocaml/bytesLabels.ml +428 -0
  586. package/lib/ocaml/bytesLabels.mli +276 -0
  587. package/lib/ocaml/callback.cmi +0 -0
  588. package/lib/ocaml/callback.cmt +0 -0
  589. package/lib/ocaml/callback.cmti +0 -0
  590. package/lib/ocaml/callback.ml +20 -0
  591. package/lib/ocaml/callback.mli +34 -0
  592. package/lib/ocaml/camlinternalLazy.cmi +0 -0
  593. package/lib/ocaml/camlinternalLazy.cmt +0 -0
  594. package/lib/ocaml/camlinternalLazy.cmti +0 -0
  595. package/lib/ocaml/camlinternalLazy.ml +89 -0
  596. package/lib/ocaml/camlinternalLazy.mli +27 -0
  597. package/lib/ocaml/camlinternalMod.cmi +0 -0
  598. package/lib/ocaml/camlinternalMod.cmt +0 -0
  599. package/lib/ocaml/camlinternalMod.cmti +0 -0
  600. package/lib/ocaml/camlinternalMod.ml +21 -0
  601. package/lib/ocaml/camlinternalMod.mli +25 -0
  602. package/lib/ocaml/char.cmi +0 -0
  603. package/lib/ocaml/char.cmt +0 -0
  604. package/lib/ocaml/char.cmti +0 -0
  605. package/lib/ocaml/char.ml +76 -0
  606. package/lib/ocaml/char.mli +72 -0
  607. package/lib/ocaml/complex.cmi +0 -0
  608. package/lib/ocaml/complex.cmt +0 -0
  609. package/lib/ocaml/complex.cmti +0 -0
  610. package/lib/ocaml/complex.ml +87 -0
  611. package/lib/ocaml/complex.mli +86 -0
  612. package/lib/ocaml/digest.cmi +0 -0
  613. package/lib/ocaml/digest.cmt +0 -0
  614. package/lib/ocaml/digest.cmti +0 -0
  615. package/lib/ocaml/digest.ml +66 -0
  616. package/lib/ocaml/digest.mli +68 -0
  617. package/lib/ocaml/dom.cmi +0 -0
  618. package/lib/ocaml/dom.cmt +0 -0
  619. package/lib/ocaml/dom.ml +296 -0
  620. package/lib/ocaml/dom_storage.cmi +0 -0
  621. package/lib/ocaml/dom_storage.cmt +0 -0
  622. package/lib/ocaml/dom_storage.ml +22 -0
  623. package/lib/ocaml/dom_storage2.cmi +0 -0
  624. package/lib/ocaml/dom_storage2.cmt +0 -0
  625. package/lib/ocaml/dom_storage2.ml +11 -0
  626. package/lib/ocaml/filename.cmi +0 -0
  627. package/lib/ocaml/filename.cmt +0 -0
  628. package/lib/ocaml/filename.cmti +0 -0
  629. package/lib/ocaml/filename.ml +233 -0
  630. package/lib/ocaml/filename.mli +134 -0
  631. package/lib/ocaml/genlex.cmi +0 -0
  632. package/lib/ocaml/genlex.cmt +0 -0
  633. package/lib/ocaml/genlex.cmti +0 -0
  634. package/lib/ocaml/genlex.ml +201 -0
  635. package/lib/ocaml/genlex.mli +73 -0
  636. package/lib/ocaml/hashmap.cppo.ml +214 -0
  637. package/lib/ocaml/hashmap.cppo.mli +54 -0
  638. package/lib/ocaml/hashset.cppo.ml +165 -0
  639. package/lib/ocaml/hashset.cppo.mli +77 -0
  640. package/lib/ocaml/hashtbl.cmi +0 -0
  641. package/lib/ocaml/hashtbl.cmt +0 -0
  642. package/lib/ocaml/hashtbl.cmti +0 -0
  643. package/lib/ocaml/hashtbl.ml +541 -0
  644. package/lib/ocaml/hashtbl.mli +411 -0
  645. package/lib/ocaml/hashtblLabels.cmi +0 -0
  646. package/lib/ocaml/hashtblLabels.cmt +0 -0
  647. package/lib/ocaml/hashtblLabels.ml +130 -0
  648. package/lib/ocaml/int32.cmi +0 -0
  649. package/lib/ocaml/int32.cmt +0 -0
  650. package/lib/ocaml/int32.cmti +0 -0
  651. package/lib/ocaml/int32.ml +64 -0
  652. package/lib/ocaml/int32.mli +186 -0
  653. package/lib/ocaml/int64.cmi +0 -0
  654. package/lib/ocaml/int64.cmt +0 -0
  655. package/lib/ocaml/int64.cmti +0 -0
  656. package/lib/ocaml/int64.ml +72 -0
  657. package/lib/ocaml/int64.mli +197 -0
  658. package/lib/ocaml/internal_map.cppo.ml +230 -0
  659. package/lib/ocaml/internal_set.cppo.ml +134 -0
  660. package/lib/ocaml/js.cmi +0 -0
  661. package/lib/ocaml/js.cmt +0 -0
  662. package/lib/ocaml/js.ml +313 -0
  663. package/lib/ocaml/js_OO.cmi +0 -0
  664. package/lib/ocaml/js_OO.cmt +0 -0
  665. package/lib/ocaml/js_OO.ml +180 -0
  666. package/lib/ocaml/js_array.cmi +0 -0
  667. package/lib/ocaml/js_array.cmt +0 -0
  668. package/lib/ocaml/js_array.ml +970 -0
  669. package/lib/ocaml/js_array2.cmi +0 -0
  670. package/lib/ocaml/js_array2.cmt +0 -0
  671. package/lib/ocaml/js_array2.ml +1065 -0
  672. package/lib/ocaml/js_bigint.cmi +0 -0
  673. package/lib/ocaml/js_bigint.cmt +0 -0
  674. package/lib/ocaml/js_bigint.ml +3 -0
  675. package/lib/ocaml/js_cast.cmi +0 -0
  676. package/lib/ocaml/js_cast.cmt +0 -0
  677. package/lib/ocaml/js_cast.cmti +0 -0
  678. package/lib/ocaml/js_cast.ml +29 -0
  679. package/lib/ocaml/js_cast.mli +45 -0
  680. package/lib/ocaml/js_console.cmi +0 -0
  681. package/lib/ocaml/js_console.cmt +0 -0
  682. package/lib/ocaml/js_console.ml +51 -0
  683. package/lib/ocaml/js_date.cmi +0 -0
  684. package/lib/ocaml/js_date.cmt +0 -0
  685. package/lib/ocaml/js_date.ml +1263 -0
  686. package/lib/ocaml/js_dict.cmi +0 -0
  687. package/lib/ocaml/js_dict.cmt +0 -0
  688. package/lib/ocaml/js_dict.cmti +0 -0
  689. package/lib/ocaml/js_dict.ml +114 -0
  690. package/lib/ocaml/js_dict.mli +152 -0
  691. package/lib/ocaml/js_exn.cmi +0 -0
  692. package/lib/ocaml/js_exn.cmt +0 -0
  693. package/lib/ocaml/js_exn.cmti +0 -0
  694. package/lib/ocaml/js_exn.ml +102 -0
  695. package/lib/ocaml/js_exn.mli +79 -0
  696. package/lib/ocaml/js_float.cmi +0 -0
  697. package/lib/ocaml/js_float.cmt +0 -0
  698. package/lib/ocaml/js_float.ml +294 -0
  699. package/lib/ocaml/js_global.cmi +0 -0
  700. package/lib/ocaml/js_global.cmt +0 -0
  701. package/lib/ocaml/js_global.ml +185 -0
  702. package/lib/ocaml/js_int.cmi +0 -0
  703. package/lib/ocaml/js_int.cmt +0 -0
  704. package/lib/ocaml/js_int.ml +158 -0
  705. package/lib/ocaml/js_json.cmi +0 -0
  706. package/lib/ocaml/js_json.cmt +0 -0
  707. package/lib/ocaml/js_json.cmti +0 -0
  708. package/lib/ocaml/js_json.ml +195 -0
  709. package/lib/ocaml/js_json.mli +244 -0
  710. package/lib/ocaml/js_list.cmi +0 -0
  711. package/lib/ocaml/js_list.cmt +0 -0
  712. package/lib/ocaml/js_list.cmti +0 -0
  713. package/lib/ocaml/js_list.ml +174 -0
  714. package/lib/ocaml/js_list.mli +72 -0
  715. package/lib/ocaml/js_map.cmi +0 -0
  716. package/lib/ocaml/js_map.cmt +0 -0
  717. package/lib/ocaml/js_map.ml +3 -0
  718. package/lib/ocaml/js_mapperRt.cmi +0 -0
  719. package/lib/ocaml/js_mapperRt.cmt +0 -0
  720. package/lib/ocaml/js_mapperRt.cmti +0 -0
  721. package/lib/ocaml/js_mapperRt.ml +50 -0
  722. package/lib/ocaml/js_mapperRt.mli +44 -0
  723. package/lib/ocaml/js_math.cmi +0 -0
  724. package/lib/ocaml/js_math.cmt +0 -0
  725. package/lib/ocaml/js_math.ml +626 -0
  726. package/lib/ocaml/js_null.cmi +0 -0
  727. package/lib/ocaml/js_null.cmt +0 -0
  728. package/lib/ocaml/js_null.cmti +0 -0
  729. package/lib/ocaml/js_null.ml +57 -0
  730. package/lib/ocaml/js_null.mli +87 -0
  731. package/lib/ocaml/js_null_undefined.cmi +0 -0
  732. package/lib/ocaml/js_null_undefined.cmt +0 -0
  733. package/lib/ocaml/js_null_undefined.cmti +0 -0
  734. package/lib/ocaml/js_null_undefined.ml +50 -0
  735. package/lib/ocaml/js_null_undefined.mli +85 -0
  736. package/lib/ocaml/js_obj.cmi +0 -0
  737. package/lib/ocaml/js_obj.cmt +0 -0
  738. package/lib/ocaml/js_obj.ml +100 -0
  739. package/lib/ocaml/js_option.cmi +0 -0
  740. package/lib/ocaml/js_option.cmt +0 -0
  741. package/lib/ocaml/js_option.cmti +0 -0
  742. package/lib/ocaml/js_option.ml +203 -0
  743. package/lib/ocaml/js_option.mli +52 -0
  744. package/lib/ocaml/js_promise.cmi +0 -0
  745. package/lib/ocaml/js_promise.cmt +0 -0
  746. package/lib/ocaml/js_promise.ml +100 -0
  747. package/lib/ocaml/js_re.cmi +0 -0
  748. package/lib/ocaml/js_re.cmt +0 -0
  749. package/lib/ocaml/js_re.ml +184 -0
  750. package/lib/ocaml/js_result.cmi +0 -0
  751. package/lib/ocaml/js_result.cmt +0 -0
  752. package/lib/ocaml/js_result.cmti +0 -0
  753. package/lib/ocaml/js_result.ml +28 -0
  754. package/lib/ocaml/js_result.mli +28 -0
  755. package/lib/ocaml/js_set.cmi +0 -0
  756. package/lib/ocaml/js_set.cmt +0 -0
  757. package/lib/ocaml/js_set.ml +3 -0
  758. package/lib/ocaml/js_string.cmi +0 -0
  759. package/lib/ocaml/js_string.cmt +0 -0
  760. package/lib/ocaml/js_string.ml +914 -0
  761. package/lib/ocaml/js_string2.cmi +0 -0
  762. package/lib/ocaml/js_string2.cmt +0 -0
  763. package/lib/ocaml/js_string2.ml +912 -0
  764. package/lib/ocaml/js_typed_array.cmi +0 -0
  765. package/lib/ocaml/js_typed_array.cmt +0 -0
  766. package/lib/ocaml/js_typed_array.cppo.ml +429 -0
  767. package/lib/ocaml/js_typed_array.ml +1405 -0
  768. package/lib/ocaml/js_typed_array2.cmi +0 -0
  769. package/lib/ocaml/js_typed_array2.cmt +0 -0
  770. package/lib/ocaml/js_typed_array2.cppo.ml +296 -0
  771. package/lib/ocaml/js_typed_array2.ml +1269 -0
  772. package/lib/ocaml/js_types.cmi +0 -0
  773. package/lib/ocaml/js_types.cmt +0 -0
  774. package/lib/ocaml/js_types.cmti +0 -0
  775. package/lib/ocaml/js_types.ml +118 -0
  776. package/lib/ocaml/js_types.mli +78 -0
  777. package/lib/ocaml/js_undefined.cmi +0 -0
  778. package/lib/ocaml/js_undefined.cmt +0 -0
  779. package/lib/ocaml/js_undefined.cmti +0 -0
  780. package/lib/ocaml/js_undefined.ml +59 -0
  781. package/lib/ocaml/js_undefined.mli +92 -0
  782. package/lib/ocaml/js_vector.cmi +0 -0
  783. package/lib/ocaml/js_vector.cmt +0 -0
  784. package/lib/ocaml/js_vector.cmti +0 -0
  785. package/lib/ocaml/js_vector.ml +143 -0
  786. package/lib/ocaml/js_vector.mli +92 -0
  787. package/lib/ocaml/js_weakmap.cmi +0 -0
  788. package/lib/ocaml/js_weakmap.cmt +0 -0
  789. package/lib/ocaml/js_weakmap.ml +3 -0
  790. package/lib/ocaml/js_weakset.cmi +0 -0
  791. package/lib/ocaml/js_weakset.cmt +0 -0
  792. package/lib/ocaml/js_weakset.ml +3 -0
  793. package/lib/ocaml/jsx.cmi +0 -0
  794. package/lib/ocaml/jsx.cmt +0 -0
  795. package/lib/ocaml/jsx.ml +39 -0
  796. package/lib/ocaml/jsxDOM.cmi +0 -0
  797. package/lib/ocaml/jsxDOM.cmt +0 -0
  798. package/lib/ocaml/jsxDOM.ml +2087 -0
  799. package/lib/ocaml/jsxDOMStyle.cmi +0 -0
  800. package/lib/ocaml/jsxDOMStyle.cmt +0 -0
  801. package/lib/ocaml/jsxDOMStyle.ml +777 -0
  802. package/lib/ocaml/jsxEvent.cmi +0 -0
  803. package/lib/ocaml/jsxEvent.cmt +0 -0
  804. package/lib/ocaml/jsxEvent.ml +358 -0
  805. package/lib/ocaml/lazy.cmi +0 -0
  806. package/lib/ocaml/lazy.cmt +0 -0
  807. package/lib/ocaml/lazy.cmti +0 -0
  808. package/lib/ocaml/lazy.ml +70 -0
  809. package/lib/ocaml/lazy.mli +95 -0
  810. package/lib/ocaml/lexing.cmi +0 -0
  811. package/lib/ocaml/lexing.cmt +0 -0
  812. package/lib/ocaml/lexing.cmti +0 -0
  813. package/lib/ocaml/lexing.ml +230 -0
  814. package/lib/ocaml/lexing.mli +172 -0
  815. package/lib/ocaml/list.cmi +0 -0
  816. package/lib/ocaml/list.cmt +0 -0
  817. package/lib/ocaml/list.cmti +0 -0
  818. package/lib/ocaml/list.ml +485 -0
  819. package/lib/ocaml/list.mli +347 -0
  820. package/lib/ocaml/listLabels.cmi +0 -0
  821. package/lib/ocaml/listLabels.cmt +0 -0
  822. package/lib/ocaml/listLabels.cmti +0 -0
  823. package/lib/ocaml/listLabels.ml +485 -0
  824. package/lib/ocaml/listLabels.mli +353 -0
  825. package/lib/ocaml/map.cmi +0 -0
  826. package/lib/ocaml/map.cmt +0 -0
  827. package/lib/ocaml/map.cmti +0 -0
  828. package/lib/ocaml/map.cppo.ml +174 -0
  829. package/lib/ocaml/map.cppo.mli +191 -0
  830. package/lib/ocaml/map.ml +480 -0
  831. package/lib/ocaml/map.mli +315 -0
  832. package/lib/ocaml/mapLabels.cmi +0 -0
  833. package/lib/ocaml/mapLabels.cmt +0 -0
  834. package/lib/ocaml/mapLabels.ml +480 -0
  835. package/lib/ocaml/mapm.cppo.ml +177 -0
  836. package/lib/ocaml/mapm.cppo.mli +138 -0
  837. package/lib/ocaml/moreLabels.cmi +0 -0
  838. package/lib/ocaml/moreLabels.cmt +0 -0
  839. package/lib/ocaml/moreLabels.cmti +0 -0
  840. package/lib/ocaml/moreLabels.ml +22 -0
  841. package/lib/ocaml/moreLabels.mli +198 -0
  842. package/lib/ocaml/node.cmi +0 -0
  843. package/lib/ocaml/node.cmt +0 -0
  844. package/lib/ocaml/node.ml +84 -0
  845. package/lib/ocaml/node_buffer.cmi +0 -0
  846. package/lib/ocaml/node_buffer.cmt +0 -0
  847. package/lib/ocaml/node_buffer.ml +47 -0
  848. package/lib/ocaml/node_child_process.cmi +0 -0
  849. package/lib/ocaml/node_child_process.cmt +0 -0
  850. package/lib/ocaml/node_child_process.ml +50 -0
  851. package/lib/ocaml/node_fs.cmi +0 -0
  852. package/lib/ocaml/node_fs.cmt +0 -0
  853. package/lib/ocaml/node_fs.ml +153 -0
  854. package/lib/ocaml/node_module.cmi +0 -0
  855. package/lib/ocaml/node_module.cmt +0 -0
  856. package/lib/ocaml/node_module.ml +29 -0
  857. package/lib/ocaml/node_path.cmi +0 -0
  858. package/lib/ocaml/node_path.cmt +0 -0
  859. package/lib/ocaml/node_path.ml +71 -0
  860. package/lib/ocaml/node_process.cmi +0 -0
  861. package/lib/ocaml/node_process.cmt +0 -0
  862. package/lib/ocaml/node_process.cmti +0 -0
  863. package/lib/ocaml/node_process.ml +59 -0
  864. package/lib/ocaml/node_process.mli +48 -0
  865. package/lib/ocaml/obj.cmi +0 -0
  866. package/lib/ocaml/obj.cmt +0 -0
  867. package/lib/ocaml/obj.cmti +0 -0
  868. package/lib/ocaml/obj.ml +29 -0
  869. package/lib/ocaml/obj.mli +62 -0
  870. package/lib/ocaml/parsing.cmi +0 -0
  871. package/lib/ocaml/parsing.cmt +0 -0
  872. package/lib/ocaml/parsing.cmti +0 -0
  873. package/lib/ocaml/parsing.ml +212 -0
  874. package/lib/ocaml/parsing.mli +105 -0
  875. package/lib/ocaml/pervasives.cmi +0 -0
  876. package/lib/ocaml/pervasives.cmt +0 -0
  877. package/lib/ocaml/pervasives.cmti +0 -0
  878. package/lib/ocaml/pervasives.ml +297 -0
  879. package/lib/ocaml/pervasives.mli +771 -0
  880. package/lib/ocaml/printexc.cmi +0 -0
  881. package/lib/ocaml/printexc.cmt +0 -0
  882. package/lib/ocaml/printexc.cmti +0 -0
  883. package/lib/ocaml/printexc.ml +79 -0
  884. package/lib/ocaml/printexc.mli +57 -0
  885. package/lib/ocaml/queue.cmi +0 -0
  886. package/lib/ocaml/queue.cmt +0 -0
  887. package/lib/ocaml/queue.cmti +0 -0
  888. package/lib/ocaml/queue.ml +132 -0
  889. package/lib/ocaml/queue.mli +82 -0
  890. package/lib/ocaml/random.cmi +0 -0
  891. package/lib/ocaml/random.cmt +0 -0
  892. package/lib/ocaml/random.cmti +0 -0
  893. package/lib/ocaml/random.ml +273 -0
  894. package/lib/ocaml/random.mli +102 -0
  895. package/lib/ocaml/set.cmi +0 -0
  896. package/lib/ocaml/set.cmt +0 -0
  897. package/lib/ocaml/set.cmti +0 -0
  898. package/lib/ocaml/set.ml +526 -0
  899. package/lib/ocaml/set.mli +266 -0
  900. package/lib/ocaml/setLabels.cmi +0 -0
  901. package/lib/ocaml/setLabels.cmt +0 -0
  902. package/lib/ocaml/setLabels.ml +526 -0
  903. package/lib/ocaml/setm.cppo.ml +346 -0
  904. package/lib/ocaml/setm.cppo.mli +126 -0
  905. package/lib/ocaml/sort.cmi +0 -0
  906. package/lib/ocaml/sort.cmt +0 -0
  907. package/lib/ocaml/sort.cmti +0 -0
  908. package/lib/ocaml/sort.cppo.ml +267 -0
  909. package/lib/ocaml/sort.cppo.mli +96 -0
  910. package/lib/ocaml/sort.ml +99 -0
  911. package/lib/ocaml/sort.mli +44 -0
  912. package/lib/ocaml/stack.cmi +0 -0
  913. package/lib/ocaml/stack.cmt +0 -0
  914. package/lib/ocaml/stack.cmti +0 -0
  915. package/lib/ocaml/stack.ml +44 -0
  916. package/lib/ocaml/stack.mli +63 -0
  917. package/lib/ocaml/stdLabels.cmi +0 -0
  918. package/lib/ocaml/stdLabels.cmt +0 -0
  919. package/lib/ocaml/stdLabels.cmti +0 -0
  920. package/lib/ocaml/stdLabels.ml +24 -0
  921. package/lib/ocaml/stdLabels.mli +29 -0
  922. package/lib/ocaml/stream.cmi +0 -0
  923. package/lib/ocaml/stream.cmt +0 -0
  924. package/lib/ocaml/stream.cmti +0 -0
  925. package/lib/ocaml/stream.ml +213 -0
  926. package/lib/ocaml/stream.mli +108 -0
  927. package/lib/ocaml/string.cmi +0 -0
  928. package/lib/ocaml/string.cmt +0 -0
  929. package/lib/ocaml/string.cmti +0 -0
  930. package/lib/ocaml/string.ml +190 -0
  931. package/lib/ocaml/string.mli +286 -0
  932. package/lib/ocaml/stringLabels.cmi +0 -0
  933. package/lib/ocaml/stringLabels.cmt +0 -0
  934. package/lib/ocaml/stringLabels.cmti +0 -0
  935. package/lib/ocaml/stringLabels.ml +190 -0
  936. package/lib/ocaml/stringLabels.mli +241 -0
  937. package/lib/ocaml/sys.cmi +0 -0
  938. package/lib/ocaml/sys.cmt +0 -0
  939. package/lib/ocaml/sys.cmti +0 -0
  940. package/lib/ocaml/sys.ml +135 -0
  941. package/lib/ocaml/sys.mli +333 -0
  942. package/lib/ocaml/uchar.cmi +0 -0
  943. package/lib/ocaml/uchar.cmt +0 -0
  944. package/lib/ocaml/uchar.cmti +0 -0
  945. package/lib/ocaml/uchar.ml +58 -0
  946. package/lib/ocaml/uchar.mli +98 -0
  947. package/linux/bsb_helper.exe +0 -0
  948. package/linux/bsc.exe +0 -0
  949. package/linux/ninja.COPYING +202 -0
  950. package/linux/ninja.exe +0 -0
  951. package/linux/refmt.exe +0 -0
  952. package/linux/rescript.exe +0 -0
  953. package/openbsd/.keep +0 -0
  954. package/package.json +71 -0
  955. package/rescript +591 -0
  956. package/scripts/LICENSE.ml +27 -0
  957. package/scripts/bin_path.js +38 -0
  958. package/scripts/buckle_lto.js +55 -0
  959. package/scripts/build_sorted.ml +233 -0
  960. package/scripts/buildocaml.js +102 -0
  961. package/scripts/caml_oo_curry_gen.ml +71 -0
  962. package/scripts/checkUnused.js +63 -0
  963. package/scripts/ciTest.js +172 -0
  964. package/scripts/config.js +24 -0
  965. package/scripts/cover.sh +3 -0
  966. package/scripts/curry_gen.ml +167 -0
  967. package/scripts/dbg +13 -0
  968. package/scripts/dedupe.js +44 -0
  969. package/scripts/doc_gen.js +117 -0
  970. package/scripts/install.js +237 -0
  971. package/scripts/installUtils.js +61 -0
  972. package/scripts/js_internal_gen.js +135 -0
  973. package/scripts/jsconfig.json +12 -0
  974. package/scripts/littlecase.js +21 -0
  975. package/scripts/ninja.js +1980 -0
  976. package/scripts/ninjaFactory.js +36 -0
  977. package/scripts/pack.js +107 -0
  978. package/scripts/prebuilt.js +99 -0
  979. package/scripts/release.js +41 -0
  980. package/scripts/repl.js +151 -0
  981. package/scripts/rescript_arg.js +168 -0
  982. package/scripts/rescript_convert.js +128 -0
  983. package/scripts/rescript_dump.js +48 -0
  984. package/scripts/rescript_format.js +194 -0
  985. package/scripts/shake.js +138 -0
  986. package/scripts/tasks.js +149 -0
  987. package/scripts/test.sh +3 -0
  988. package/scripts/tmp.js +98 -0
  989. package/scripts/validate.js +41 -0
  990. package/vendor/ninja.tar.gz +0 -0
  991. package/vendor/ocaml.tar.gz +0 -0
  992. package/win32/bsb_helper.exe +0 -0
  993. package/win32/bsc.exe +0 -0
  994. package/win32/ninja.COPYING +202 -0
  995. package/win32/ninja.exe +0 -0
  996. package/win32/refmt.exe +0 -0
  997. package/win32/rescript.exe +0 -0
@@ -0,0 +1,2436 @@
1
+ module Ext_pervasives : sig
2
+ #1 "ext_pervasives.mli"
3
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Lesser General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * In addition to the permissions granted to you by the LGPL, you may combine
11
+ * or link a "work that uses the Library" with a publicly distributed version
12
+ * of this file to produce a combined library or application, then distribute
13
+ * that combined work under the terms of your choosing, with no requirement
14
+ * to comply with the obligations normally placed on you by section 4 of the
15
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
16
+ * should you choose to use a later version).
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU Lesser General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU Lesser General Public License
24
+ * along with this program; if not, write to the Free Software
25
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
26
+
27
+ (** Extension to standard library [Pervavives] module, safe to open
28
+ *)
29
+
30
+ external reraise : exn -> 'a = "%reraise"
31
+
32
+ val finally : 'a -> clean:('a -> unit) -> ('a -> 'b) -> 'b
33
+
34
+ (* val try_it : (unit -> 'a) -> unit *)
35
+
36
+ val with_file_as_chan : string -> (out_channel -> 'a) -> 'a
37
+
38
+ val max_int : int -> int -> int
39
+
40
+ val min_int : int -> int -> int
41
+
42
+ val max_int_option : int option -> int option -> int option
43
+
44
+ (* external id : 'a -> 'a = "%identity" *)
45
+
46
+ (** Copied from {!Btype.hash_variant}:
47
+ need sync up and add test case
48
+ *)
49
+ (* val hash_variant : string -> int *)
50
+
51
+ (* val todo : string -> 'a *)
52
+
53
+ val nat_of_string_exn : string -> int
54
+
55
+ val parse_nat_of_string : string -> int ref -> int
56
+
57
+ end = struct
58
+ #1 "ext_pervasives.ml"
59
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
60
+ *
61
+ * This program is free software: you can redistribute it and/or modify
62
+ * it under the terms of the GNU Lesser General Public License as published by
63
+ * the Free Software Foundation, either version 3 of the License, or
64
+ * (at your option) any later version.
65
+ *
66
+ * In addition to the permissions granted to you by the LGPL, you may combine
67
+ * or link a "work that uses the Library" with a publicly distributed version
68
+ * of this file to produce a combined library or application, then distribute
69
+ * that combined work under the terms of your choosing, with no requirement
70
+ * to comply with the obligations normally placed on you by section 4 of the
71
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
72
+ * should you choose to use a later version).
73
+ *
74
+ * This program is distributed in the hope that it will be useful,
75
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
76
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77
+ * GNU Lesser General Public License for more details.
78
+ *
79
+ * You should have received a copy of the GNU Lesser General Public License
80
+ * along with this program; if not, write to the Free Software
81
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
82
+
83
+ external reraise : exn -> 'a = "%reraise"
84
+
85
+ let finally v ~clean:action f =
86
+ match f v with
87
+ | exception e ->
88
+ action v;
89
+ reraise e
90
+ | e ->
91
+ action v;
92
+ e
93
+
94
+ (* let try_it f =
95
+ try ignore (f ()) with _ -> () *)
96
+
97
+ let with_file_as_chan filename f =
98
+ finally (open_out_bin filename) ~clean:close_out f
99
+
100
+ let max_int (x : int) y = if x >= y then x else y
101
+
102
+ let min_int (x : int) y = if x < y then x else y
103
+
104
+ let max_int_option (x : int option) y =
105
+ match (x, y) with
106
+ | None, _ -> y
107
+ | Some _, None -> x
108
+ | Some x0, Some y0 -> if x0 >= y0 then x else y
109
+
110
+ (* external id : 'a -> 'a = "%identity" *)
111
+
112
+ (*
113
+ let hash_variant s =
114
+ let accu = ref 0 in
115
+ for i = 0 to String.length s - 1 do
116
+ accu := 223 * !accu + Char.code s.[i]
117
+ done;
118
+ (* reduce to 31 bits *)
119
+ accu := !accu land (1 lsl 31 - 1);
120
+ (* make it signed for 64 bits architectures *)
121
+ if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu *)
122
+
123
+ (* let todo loc =
124
+ failwith (loc ^ " Not supported yet")
125
+ *)
126
+
127
+ let rec int_of_string_aux s acc off len =
128
+ if off >= len then acc
129
+ else
130
+ let d = Char.code (String.unsafe_get s off) - 48 in
131
+ if d >= 0 && d <= 9 then int_of_string_aux s ((10 * acc) + d) (off + 1) len
132
+ else -1
133
+ (* error *)
134
+
135
+ let nat_of_string_exn (s : string) =
136
+ let acc = int_of_string_aux s 0 0 (String.length s) in
137
+ if acc < 0 then invalid_arg s else acc
138
+
139
+ (** return index *)
140
+ let parse_nat_of_string (s : string) (cursor : int ref) =
141
+ let current = !cursor in
142
+ assert (current >= 0);
143
+ let acc = ref 0 in
144
+ let s_len = String.length s in
145
+ let todo = ref true in
146
+ let cur = ref current in
147
+ while !todo && !cursor < s_len do
148
+ let d = Char.code (String.unsafe_get s !cur) - 48 in
149
+ if d >= 0 && d <= 9 then (
150
+ acc := (10 * !acc) + d;
151
+ incr cur)
152
+ else todo := false
153
+ done;
154
+ cursor := !cur;
155
+ !acc
156
+
157
+ end
158
+ module Ext_io : sig
159
+ #1 "ext_io.mli"
160
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
161
+ *
162
+ * This program is free software: you can redistribute it and/or modify
163
+ * it under the terms of the GNU Lesser General Public License as published by
164
+ * the Free Software Foundation, either version 3 of the License, or
165
+ * (at your option) any later version.
166
+ *
167
+ * In addition to the permissions granted to you by the LGPL, you may combine
168
+ * or link a "work that uses the Library" with a publicly distributed version
169
+ * of this file to produce a combined library or application, then distribute
170
+ * that combined work under the terms of your choosing, with no requirement
171
+ * to comply with the obligations normally placed on you by section 4 of the
172
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
173
+ * should you choose to use a later version).
174
+ *
175
+ * This program is distributed in the hope that it will be useful,
176
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
177
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
178
+ * GNU Lesser General Public License for more details.
179
+ *
180
+ * You should have received a copy of the GNU Lesser General Public License
181
+ * along with this program; if not, write to the Free Software
182
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
183
+
184
+ val load_file : string -> string
185
+
186
+ val rev_lines_of_file : string -> string list
187
+
188
+ val rev_lines_of_chann : in_channel -> string list
189
+
190
+ val write_file : string -> string -> unit
191
+
192
+ end = struct
193
+ #1 "ext_io.ml"
194
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
195
+ *
196
+ * This program is free software: you can redistribute it and/or modify
197
+ * it under the terms of the GNU Lesser General Public License as published by
198
+ * the Free Software Foundation, either version 3 of the License, or
199
+ * (at your option) any later version.
200
+ *
201
+ * In addition to the permissions granted to you by the LGPL, you may combine
202
+ * or link a "work that uses the Library" with a publicly distributed version
203
+ * of this file to produce a combined library or application, then distribute
204
+ * that combined work under the terms of your choosing, with no requirement
205
+ * to comply with the obligations normally placed on you by section 4 of the
206
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
207
+ * should you choose to use a later version).
208
+ *
209
+ * This program is distributed in the hope that it will be useful,
210
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
211
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212
+ * GNU Lesser General Public License for more details.
213
+ *
214
+ * You should have received a copy of the GNU Lesser General Public License
215
+ * along with this program; if not, write to the Free Software
216
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
217
+
218
+ (** on 32 bit , there are 16M limitation *)
219
+ let load_file f =
220
+ Ext_pervasives.finally (open_in_bin f) ~clean:close_in (fun ic ->
221
+ let n = in_channel_length ic in
222
+ let s = Bytes.create n in
223
+ really_input ic s 0 n;
224
+ Bytes.unsafe_to_string s)
225
+
226
+ let rev_lines_of_chann chan =
227
+ let rec loop acc chan =
228
+ match input_line chan with
229
+ | line -> loop (line :: acc) chan
230
+ | exception End_of_file ->
231
+ close_in chan;
232
+ acc
233
+ in
234
+ loop [] chan
235
+
236
+ let rev_lines_of_file file =
237
+ Ext_pervasives.finally ~clean:close_in (open_in_bin file) rev_lines_of_chann
238
+
239
+ let write_file f content =
240
+ Ext_pervasives.finally ~clean:close_out (open_out_bin f) (fun oc ->
241
+ output_string oc content)
242
+
243
+ end
244
+ module Ext_bytes : sig
245
+ #1 "ext_bytes.mli"
246
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
247
+ *
248
+ * This program is free software: you can redistribute it and/or modify
249
+ * it under the terms of the GNU Lesser General Public License as published by
250
+ * the Free Software Foundation, either version 3 of the License, or
251
+ * (at your option) any later version.
252
+ *
253
+ * In addition to the permissions granted to you by the LGPL, you may combine
254
+ * or link a "work that uses the Library" with a publicly distributed version
255
+ * of this file to produce a combined library or application, then distribute
256
+ * that combined work under the terms of your choosing, with no requirement
257
+ * to comply with the obligations normally placed on you by section 4 of the
258
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
259
+ * should you choose to use a later version).
260
+ *
261
+ * This program is distributed in the hope that it will be useful,
262
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
263
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264
+ * GNU Lesser General Public License for more details.
265
+ *
266
+ * You should have received a copy of the GNU Lesser General Public License
267
+ * along with this program; if not, write to the Free Software
268
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
269
+
270
+ external unsafe_blit_string : string -> int -> bytes -> int -> int -> unit
271
+ = "caml_blit_string"
272
+ [@@noalloc]
273
+
274
+ end = struct
275
+ #1 "ext_bytes.ml"
276
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
277
+ *
278
+ * This program is free software: you can redistribute it and/or modify
279
+ * it under the terms of the GNU Lesser General Public License as published by
280
+ * the Free Software Foundation, either version 3 of the License, or
281
+ * (at your option) any later version.
282
+ *
283
+ * In addition to the permissions granted to you by the LGPL, you may combine
284
+ * or link a "work that uses the Library" with a publicly distributed version
285
+ * of this file to produce a combined library or application, then distribute
286
+ * that combined work under the terms of your choosing, with no requirement
287
+ * to comply with the obligations normally placed on you by section 4 of the
288
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
289
+ * should you choose to use a later version).
290
+ *
291
+ * This program is distributed in the hope that it will be useful,
292
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
293
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
294
+ * GNU Lesser General Public License for more details.
295
+ *
296
+ * You should have received a copy of the GNU Lesser General Public License
297
+ * along with this program; if not, write to the Free Software
298
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
299
+
300
+ external unsafe_blit_string : string -> int -> bytes -> int -> int -> unit
301
+ = "caml_blit_string"
302
+ [@@noalloc]
303
+
304
+ end
305
+ module Ext_string : sig
306
+ #1 "ext_string.pp.mli"
307
+ (* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
308
+ * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
309
+ * This program is free software: you can redistribute it and/or modify
310
+ * it under the terms of the GNU Lesser General Public License as published by
311
+ * the Free Software Foundation, either version 3 of the License, or
312
+ * (at your option) any later version.
313
+ *
314
+ * In addition to the permissions granted to you by the LGPL, you may combine
315
+ * or link a "work that uses the Library" with a publicly distributed version
316
+ * of this file to produce a combined library or application, then distribute
317
+ * that combined work under the terms of your choosing, with no requirement
318
+ * to comply with the obligations normally placed on you by section 4 of the
319
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
320
+ * should you choose to use a later version).
321
+ *
322
+ * This program is distributed in the hope that it will be useful,
323
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
324
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
325
+ * GNU Lesser General Public License for more details.
326
+ *
327
+ * You should have received a copy of the GNU Lesser General Public License
328
+ * along with this program; if not, write to the Free Software
329
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+ (** Extension to the standard library [String] module, fixed some bugs like
339
+ avoiding locale sensitivity *)
340
+
341
+ (** default is false *)
342
+ val split_by : ?keep_empty:bool -> (char -> bool) -> string -> string list
343
+
344
+
345
+ (** remove whitespace letters ('\t', '\n', ' ') on both side*)
346
+ val trim : string -> string
347
+
348
+
349
+ (** default is false *)
350
+ val split : ?keep_empty:bool -> string -> char -> string list
351
+
352
+ (** split by space chars for quick scripting *)
353
+ val quick_split_by_ws : string -> string list
354
+
355
+
356
+
357
+ val starts_with : string -> string -> bool
358
+
359
+ (**
360
+ return [-1] when not found, the returned index is useful
361
+ see [ends_with_then_chop]
362
+ *)
363
+ val ends_with_index : string -> string -> int
364
+
365
+ val ends_with : string -> string -> bool
366
+
367
+ (**
368
+ [ends_with_then_chop name ext]
369
+ @example:
370
+ {[
371
+ ends_with_then_chop "a.cmj" ".cmj"
372
+ "a"
373
+ ]}
374
+ This is useful in controlled or file case sensitve system
375
+ *)
376
+ val ends_with_then_chop : string -> string -> string option
377
+
378
+
379
+
380
+
381
+ (**
382
+ [for_all_from s start p]
383
+ if [start] is negative, it raises,
384
+ if [start] is too large, it returns true
385
+ *)
386
+ val for_all_from:
387
+ string ->
388
+ int ->
389
+ (char -> bool) ->
390
+ bool
391
+
392
+ val for_all :
393
+ string ->
394
+ (char -> bool) ->
395
+ bool
396
+
397
+ val is_empty : string -> bool
398
+
399
+ val repeat : int -> string -> string
400
+
401
+ val equal : string -> string -> bool
402
+
403
+ (**
404
+ [extract_until s cursor sep]
405
+ When [sep] not found, the cursor is updated to -1,
406
+ otherwise cursor is increased to 1 + [sep_position]
407
+ User can not determine whether it is found or not by
408
+ telling the return string is empty since
409
+ "\n\n" would result in an empty string too.
410
+ *)
411
+ (* val extract_until:
412
+ string ->
413
+ int ref -> (* cursor to be updated *)
414
+ char ->
415
+ string *)
416
+
417
+ val index_count:
418
+ string ->
419
+ int ->
420
+ char ->
421
+ int ->
422
+ int
423
+
424
+ (* val index_next :
425
+ string ->
426
+ int ->
427
+ char ->
428
+ int *)
429
+
430
+
431
+ (**
432
+ [find ~start ~sub s]
433
+ returns [-1] if not found
434
+ *)
435
+ val find : ?start:int -> sub:string -> string -> int
436
+
437
+ val contain_substring : string -> string -> bool
438
+
439
+ val non_overlap_count : sub:string -> string -> int
440
+
441
+ val rfind : sub:string -> string -> int
442
+
443
+ (** [tail_from s 1]
444
+ return a substring from offset 1 (inclusive)
445
+ *)
446
+ val tail_from : string -> int -> string
447
+
448
+
449
+ (** returns negative number if not found *)
450
+ val rindex_neg : string -> char -> int
451
+
452
+ val rindex_opt : string -> char -> int option
453
+
454
+
455
+ val no_char : string -> char -> int -> int -> bool
456
+
457
+
458
+ val no_slash : string -> bool
459
+
460
+ (** return negative means no slash, otherwise [i] means the place for first slash *)
461
+ val no_slash_idx : string -> int
462
+
463
+ val no_slash_idx_from : string -> int -> int
464
+
465
+ (** if no conversion happens, reference equality holds *)
466
+ val replace_slash_backward : string -> string
467
+
468
+ (** if no conversion happens, reference equality holds *)
469
+ val replace_backward_slash : string -> string
470
+
471
+ val empty : string
472
+
473
+
474
+ external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
475
+
476
+ val single_space : string
477
+
478
+ val concat3 : string -> string -> string -> string
479
+ val concat4 : string -> string -> string -> string -> string
480
+ val concat5 : string -> string -> string -> string -> string -> string
481
+ val inter2 : string -> string -> string
482
+ val inter3 : string -> string -> string -> string
483
+ val inter4 : string -> string -> string -> string -> string
484
+ val concat_array : string -> string array -> string
485
+
486
+ val single_colon : string
487
+
488
+ val parent_dir_lit : string
489
+ val current_dir_lit : string
490
+
491
+ val capitalize_ascii : string -> string
492
+
493
+ val capitalize_sub:
494
+ string ->
495
+ int ->
496
+ string
497
+
498
+ val uncapitalize_ascii : string -> string
499
+
500
+ val lowercase_ascii : string -> string
501
+
502
+ (** Play parity to {!Ext_buffer.add_int_1} *)
503
+ (* val get_int_1 : string -> int -> int
504
+ val get_int_2 : string -> int -> int
505
+ val get_int_3 : string -> int -> int
506
+ val get_int_4 : string -> int -> int *)
507
+
508
+ val get_1_2_3_4 :
509
+ string ->
510
+ off:int ->
511
+ int ->
512
+ int
513
+
514
+ val unsafe_sub :
515
+ string ->
516
+ int ->
517
+ int ->
518
+ string
519
+
520
+ val is_valid_hash_number:
521
+ string ->
522
+ bool
523
+
524
+ val hash_number_as_i32_exn:
525
+ string ->
526
+ int32
527
+
528
+ val first_marshal_char:
529
+ string ->
530
+ bool
531
+ end = struct
532
+ #1 "ext_string.pp.ml"
533
+ (* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
534
+ * Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
535
+ * This program is free software: you can redistribute it and/or modify
536
+ * it under the terms of the GNU Lesser General Public License as published by
537
+ * the Free Software Foundation, either version 3 of the License, or
538
+ * (at your option) any later version.
539
+ *
540
+ * In addition to the permissions granted to you by the LGPL, you may combine
541
+ * or link a "work that uses the Library" with a publicly distributed version
542
+ * of this file to produce a combined library or application, then distribute
543
+ * that combined work under the terms of your choosing, with no requirement
544
+ * to comply with the obligations normally placed on you by section 4 of the
545
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
546
+ * should you choose to use a later version).
547
+ *
548
+ * This program is distributed in the hope that it will be useful,
549
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
550
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
551
+ * GNU Lesser General Public License for more details.
552
+ *
553
+ * You should have received a copy of the GNU Lesser General Public License
554
+ * along with this program; if not, write to the Free Software
555
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+ (*
564
+ {[ split " test_unsafe_obj_ffi_ppx.cmi" ~keep_empty:false ' ']}
565
+ *)
566
+ let split_by ?(keep_empty=false) is_delim str =
567
+ let len = String.length str in
568
+ let rec loop acc last_pos pos =
569
+ if pos = -1 then
570
+ if last_pos = 0 && not keep_empty then
571
+
572
+ acc
573
+ else
574
+ String.sub str 0 last_pos :: acc
575
+ else
576
+ if is_delim str.[pos] then
577
+ let new_len = (last_pos - pos - 1) in
578
+ if new_len <> 0 || keep_empty then
579
+ let v = String.sub str (pos + 1) new_len in
580
+ loop ( v :: acc)
581
+ pos (pos - 1)
582
+ else loop acc pos (pos - 1)
583
+ else loop acc last_pos (pos - 1)
584
+ in
585
+ loop [] len (len - 1)
586
+
587
+ let trim s =
588
+ let i = ref 0 in
589
+ let j = String.length s in
590
+ while !i < j &&
591
+ let u = String.unsafe_get s !i in
592
+ u = '\t' || u = '\n' || u = ' '
593
+ do
594
+ incr i;
595
+ done;
596
+ let k = ref (j - 1) in
597
+ while !k >= !i &&
598
+ let u = String.unsafe_get s !k in
599
+ u = '\t' || u = '\n' || u = ' ' do
600
+ decr k ;
601
+ done;
602
+ String.sub s !i (!k - !i + 1)
603
+
604
+ let split ?keep_empty str on =
605
+ if str = "" then [] else
606
+ split_by ?keep_empty (fun x -> (x : char) = on) str ;;
607
+
608
+ let quick_split_by_ws str : string list =
609
+ split_by ~keep_empty:false (fun x -> x = '\t' || x = '\n' || x = ' ') str
610
+
611
+ let starts_with s beg =
612
+ let beg_len = String.length beg in
613
+ let s_len = String.length s in
614
+ beg_len <= s_len &&
615
+ (let i = ref 0 in
616
+ while !i < beg_len
617
+ && String.unsafe_get s !i =
618
+ String.unsafe_get beg !i do
619
+ incr i
620
+ done;
621
+ !i = beg_len
622
+ )
623
+
624
+ let rec ends_aux s end_ j k =
625
+ if k < 0 then (j + 1)
626
+ else if String.unsafe_get s j = String.unsafe_get end_ k then
627
+ ends_aux s end_ (j - 1) (k - 1)
628
+ else -1
629
+
630
+ (** return an index which is minus when [s] does not
631
+ end with [beg]
632
+ *)
633
+ let ends_with_index s end_ : int =
634
+ let s_finish = String.length s - 1 in
635
+ let s_beg = String.length end_ - 1 in
636
+ if s_beg > s_finish then -1
637
+ else
638
+ ends_aux s end_ s_finish s_beg
639
+
640
+ let ends_with s end_ = ends_with_index s end_ >= 0
641
+
642
+ let ends_with_then_chop s beg =
643
+ let i = ends_with_index s beg in
644
+ if i >= 0 then Some (String.sub s 0 i)
645
+ else None
646
+
647
+ (* let check_suffix_case = ends_with *)
648
+ (* let check_suffix_case_then_chop = ends_with_then_chop *)
649
+
650
+ (* let check_any_suffix_case s suffixes =
651
+ Ext_list.exists suffixes (fun x -> check_suffix_case s x) *)
652
+
653
+ (* let check_any_suffix_case_then_chop s suffixes =
654
+ let rec aux suffixes =
655
+ match suffixes with
656
+ | [] -> None
657
+ | x::xs ->
658
+ let id = ends_with_index s x in
659
+ if id >= 0 then Some (String.sub s 0 id)
660
+ else aux xs in
661
+ aux suffixes *)
662
+
663
+
664
+
665
+
666
+ (* it is unsafe to expose such API as unsafe since
667
+ user can provide bad input range
668
+
669
+ *)
670
+ let rec unsafe_for_all_range s ~start ~finish p =
671
+ start > finish ||
672
+ p (String.unsafe_get s start) &&
673
+ unsafe_for_all_range s ~start:(start + 1) ~finish p
674
+
675
+ let for_all_from s start p =
676
+ let len = String.length s in
677
+ if start < 0 then invalid_arg "Ext_string.for_all_from"
678
+ else unsafe_for_all_range s ~start ~finish:(len - 1) p
679
+
680
+
681
+ let for_all s (p : char -> bool) =
682
+ unsafe_for_all_range s ~start:0 ~finish:(String.length s - 1) p
683
+
684
+ let is_empty s = String.length s = 0
685
+
686
+
687
+ let repeat n s =
688
+ let len = String.length s in
689
+ let res = Bytes.create(n * len) in
690
+ for i = 0 to pred n do
691
+ String.blit s 0 res (i * len) len
692
+ done;
693
+ Bytes.to_string res
694
+
695
+
696
+
697
+
698
+ let unsafe_is_sub ~sub i s j ~len =
699
+ let rec check k =
700
+ if k = len
701
+ then true
702
+ else
703
+ String.unsafe_get sub (i+k) =
704
+ String.unsafe_get s (j+k) && check (k+1)
705
+ in
706
+ j+len <= String.length s && check 0
707
+
708
+
709
+
710
+ let find ?(start=0) ~sub s =
711
+ let exception Local_exit in
712
+ let n = String.length sub in
713
+ let s_len = String.length s in
714
+ let i = ref start in
715
+ try
716
+ while !i + n <= s_len do
717
+ if unsafe_is_sub ~sub 0 s !i ~len:n then
718
+ raise_notrace Local_exit;
719
+ incr i
720
+ done;
721
+ -1
722
+ with Local_exit ->
723
+ !i
724
+
725
+ let contain_substring s sub =
726
+ find s ~sub >= 0
727
+
728
+ (** TODO: optimize
729
+ avoid nonterminating when string is empty
730
+ *)
731
+ let non_overlap_count ~sub s =
732
+ let sub_len = String.length sub in
733
+ let rec aux acc off =
734
+ let i = find ~start:off ~sub s in
735
+ if i < 0 then acc
736
+ else aux (acc + 1) (i + sub_len) in
737
+ if String.length sub = 0 then invalid_arg "Ext_string.non_overlap_count"
738
+ else aux 0 0
739
+
740
+
741
+ let rfind ~sub s =
742
+ let exception Local_exit in
743
+ let n = String.length sub in
744
+ let i = ref (String.length s - n) in
745
+ try
746
+ while !i >= 0 do
747
+ if unsafe_is_sub ~sub 0 s !i ~len:n then
748
+ raise_notrace Local_exit;
749
+ decr i
750
+ done;
751
+ -1
752
+ with Local_exit ->
753
+ !i
754
+
755
+ let tail_from s x =
756
+ let len = String.length s in
757
+ if x > len then invalid_arg ("Ext_string.tail_from " ^s ^ " : "^ string_of_int x )
758
+ else String.sub s x (len - x)
759
+
760
+ let equal (x : string) y = x = y
761
+
762
+ (* let rec index_rec s lim i c =
763
+ if i >= lim then -1 else
764
+ if String.unsafe_get s i = c then i
765
+ else index_rec s lim (i + 1) c *)
766
+
767
+
768
+
769
+ let rec index_rec_count s lim i c count =
770
+ if i >= lim then -1 else
771
+ if String.unsafe_get s i = c then
772
+ if count = 1 then i
773
+ else index_rec_count s lim (i + 1) c (count - 1)
774
+ else index_rec_count s lim (i + 1) c count
775
+
776
+ let index_count s i c count =
777
+ let lim = String.length s in
778
+ if i < 0 || i >= lim || count < 1 then
779
+ invalid_arg ("index_count: ( " ^string_of_int i ^ "," ^string_of_int count ^ ")" );
780
+ index_rec_count s lim i c count
781
+
782
+ (* let index_next s i c =
783
+ index_count s i c 1 *)
784
+
785
+ (* let extract_until s cursor c =
786
+ let len = String.length s in
787
+ let start = !cursor in
788
+ if start < 0 || start >= len then (
789
+ cursor := -1;
790
+ ""
791
+ )
792
+ else
793
+ let i = index_rec s len start c in
794
+ let finish =
795
+ if i < 0 then (
796
+ cursor := -1 ;
797
+ len
798
+ )
799
+ else (
800
+ cursor := i + 1;
801
+ i
802
+ ) in
803
+ String.sub s start (finish - start) *)
804
+
805
+ let rec rindex_rec s i c =
806
+ if i < 0 then i else
807
+ if String.unsafe_get s i = c then i else rindex_rec s (i - 1) c;;
808
+
809
+ let rec rindex_rec_opt s i c =
810
+ if i < 0 then None else
811
+ if String.unsafe_get s i = c then Some i else rindex_rec_opt s (i - 1) c;;
812
+
813
+ let rindex_neg s c =
814
+ rindex_rec s (String.length s - 1) c;;
815
+
816
+ let rindex_opt s c =
817
+ rindex_rec_opt s (String.length s - 1) c;;
818
+
819
+
820
+ (** TODO: can be improved to return a positive integer instead *)
821
+ let rec unsafe_no_char x ch i last_idx =
822
+ i > last_idx ||
823
+ (String.unsafe_get x i <> ch && unsafe_no_char x ch (i + 1) last_idx)
824
+
825
+ let rec unsafe_no_char_idx x ch i last_idx =
826
+ if i > last_idx then -1
827
+ else
828
+ if String.unsafe_get x i <> ch then
829
+ unsafe_no_char_idx x ch (i + 1) last_idx
830
+ else i
831
+
832
+ let no_char x ch i len : bool =
833
+ let str_len = String.length x in
834
+ if i < 0 || i >= str_len || len >= str_len then invalid_arg "Ext_string.no_char"
835
+ else unsafe_no_char x ch i len
836
+
837
+
838
+ let no_slash x =
839
+ unsafe_no_char x '/' 0 (String.length x - 1)
840
+
841
+ let no_slash_idx x =
842
+ unsafe_no_char_idx x '/' 0 (String.length x - 1)
843
+
844
+ let no_slash_idx_from x from =
845
+ let last_idx = String.length x - 1 in
846
+ assert (from >= 0);
847
+ unsafe_no_char_idx x '/' from last_idx
848
+
849
+ let replace_slash_backward (x : string ) =
850
+ let len = String.length x in
851
+ if unsafe_no_char x '/' 0 (len - 1) then x
852
+ else
853
+ String.map (function
854
+ | '/' -> '\\'
855
+ | x -> x ) x
856
+
857
+ let replace_backward_slash (x : string)=
858
+ let len = String.length x in
859
+ if unsafe_no_char x '\\' 0 (len -1) then x
860
+ else
861
+ String.map (function
862
+ |'\\'-> '/'
863
+ | x -> x) x
864
+
865
+ let empty = ""
866
+
867
+
868
+ external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
869
+
870
+ let single_space = " "
871
+ let single_colon = ":"
872
+
873
+ let concat_array sep (s : string array) =
874
+ let s_len = Array.length s in
875
+ match s_len with
876
+ | 0 -> empty
877
+ | 1 -> Array.unsafe_get s 0
878
+ | _ ->
879
+ let sep_len = String.length sep in
880
+ let len = ref 0 in
881
+ for i = 0 to s_len - 1 do
882
+ len := !len + String.length (Array.unsafe_get s i)
883
+ done;
884
+ let target =
885
+ Bytes.create
886
+ (!len + (s_len - 1) * sep_len ) in
887
+ let hd = (Array.unsafe_get s 0) in
888
+ let hd_len = String.length hd in
889
+ String.unsafe_blit hd 0 target 0 hd_len;
890
+ let current_offset = ref hd_len in
891
+ for i = 1 to s_len - 1 do
892
+ String.unsafe_blit sep 0 target !current_offset sep_len;
893
+ let cur = Array.unsafe_get s i in
894
+ let cur_len = String.length cur in
895
+ let new_off_set = (!current_offset + sep_len ) in
896
+ String.unsafe_blit cur 0 target new_off_set cur_len;
897
+ current_offset :=
898
+ new_off_set + cur_len ;
899
+ done;
900
+ Bytes.unsafe_to_string target
901
+
902
+ let concat3 a b c =
903
+ let a_len = String.length a in
904
+ let b_len = String.length b in
905
+ let c_len = String.length c in
906
+ let len = a_len + b_len + c_len in
907
+ let target = Bytes.create len in
908
+ String.unsafe_blit a 0 target 0 a_len ;
909
+ String.unsafe_blit b 0 target a_len b_len;
910
+ String.unsafe_blit c 0 target (a_len + b_len) c_len;
911
+ Bytes.unsafe_to_string target
912
+
913
+ let concat4 a b c d =
914
+ let a_len = String.length a in
915
+ let b_len = String.length b in
916
+ let c_len = String.length c in
917
+ let d_len = String.length d in
918
+ let len = a_len + b_len + c_len + d_len in
919
+
920
+ let target = Bytes.create len in
921
+ String.unsafe_blit a 0 target 0 a_len ;
922
+ String.unsafe_blit b 0 target a_len b_len;
923
+ String.unsafe_blit c 0 target (a_len + b_len) c_len;
924
+ String.unsafe_blit d 0 target (a_len + b_len + c_len) d_len;
925
+ Bytes.unsafe_to_string target
926
+
927
+
928
+ let concat5 a b c d e =
929
+ let a_len = String.length a in
930
+ let b_len = String.length b in
931
+ let c_len = String.length c in
932
+ let d_len = String.length d in
933
+ let e_len = String.length e in
934
+ let len = a_len + b_len + c_len + d_len + e_len in
935
+
936
+ let target = Bytes.create len in
937
+ String.unsafe_blit a 0 target 0 a_len ;
938
+ String.unsafe_blit b 0 target a_len b_len;
939
+ String.unsafe_blit c 0 target (a_len + b_len) c_len;
940
+ String.unsafe_blit d 0 target (a_len + b_len + c_len) d_len;
941
+ String.unsafe_blit e 0 target (a_len + b_len + c_len + d_len) e_len;
942
+ Bytes.unsafe_to_string target
943
+
944
+
945
+
946
+ let inter2 a b =
947
+ concat3 a single_space b
948
+
949
+
950
+ let inter3 a b c =
951
+ concat5 a single_space b single_space c
952
+
953
+
954
+
955
+
956
+
957
+ let inter4 a b c d =
958
+ concat_array single_space [| a; b ; c; d|]
959
+
960
+
961
+ let parent_dir_lit = ".."
962
+ let current_dir_lit = "."
963
+
964
+
965
+ (* reference {!Bytes.unppercase} *)
966
+ let capitalize_ascii (s : string) : string =
967
+ if String.length s = 0 then s
968
+ else
969
+ begin
970
+ let c = String.unsafe_get s 0 in
971
+ if (c >= 'a' && c <= 'z')
972
+ || (c >= '\224' && c <= '\246')
973
+ || (c >= '\248' && c <= '\254') then
974
+ let uc = Char.unsafe_chr (Char.code c - 32) in
975
+ let bytes = Bytes.of_string s in
976
+ Bytes.unsafe_set bytes 0 uc;
977
+ Bytes.unsafe_to_string bytes
978
+ else s
979
+ end
980
+
981
+ let capitalize_sub (s : string) len : string =
982
+ let slen = String.length s in
983
+ if len < 0 || len > slen then invalid_arg "Ext_string.capitalize_sub"
984
+ else
985
+ if len = 0 then ""
986
+ else
987
+ let bytes = Bytes.create len in
988
+ let uc =
989
+ let c = String.unsafe_get s 0 in
990
+ if (c >= 'a' && c <= 'z')
991
+ || (c >= '\224' && c <= '\246')
992
+ || (c >= '\248' && c <= '\254') then
993
+ Char.unsafe_chr (Char.code c - 32) else c in
994
+ Bytes.unsafe_set bytes 0 uc;
995
+ for i = 1 to len - 1 do
996
+ Bytes.unsafe_set bytes i (String.unsafe_get s i)
997
+ done ;
998
+ Bytes.unsafe_to_string bytes
999
+
1000
+
1001
+
1002
+ let uncapitalize_ascii =
1003
+ String.uncapitalize_ascii
1004
+
1005
+ let lowercase_ascii = String.lowercase_ascii
1006
+
1007
+ external (.![]) : string -> int -> int = "%string_unsafe_get"
1008
+
1009
+ let get_int_1_unsafe (x : string) off : int =
1010
+ x.![off]
1011
+
1012
+ let get_int_2_unsafe (x : string) off : int =
1013
+ x.![off] lor
1014
+ x.![off+1] lsl 8
1015
+
1016
+ let get_int_3_unsafe (x : string) off : int =
1017
+ x.![off] lor
1018
+ x.![off+1] lsl 8 lor
1019
+ x.![off+2] lsl 16
1020
+
1021
+
1022
+ let get_int_4_unsafe (x : string) off : int =
1023
+ x.![off] lor
1024
+ x.![off+1] lsl 8 lor
1025
+ x.![off+2] lsl 16 lor
1026
+ x.![off+3] lsl 24
1027
+
1028
+ let get_1_2_3_4 (x : string) ~off len : int =
1029
+ if len = 1 then get_int_1_unsafe x off
1030
+ else if len = 2 then get_int_2_unsafe x off
1031
+ else if len = 3 then get_int_3_unsafe x off
1032
+ else if len = 4 then get_int_4_unsafe x off
1033
+ else assert false
1034
+
1035
+ let unsafe_sub x offs len =
1036
+ let b = Bytes.create len in
1037
+ Ext_bytes.unsafe_blit_string x offs b 0 len;
1038
+ (Bytes.unsafe_to_string b)
1039
+
1040
+ let is_valid_hash_number (x:string) =
1041
+ let len = String.length x in
1042
+ len > 0 && (
1043
+ let a = x.![0] in
1044
+ a <= 57 &&
1045
+ (if len > 1 then
1046
+ a > 48 &&
1047
+ for_all_from x 1 (function '0' .. '9' -> true | _ -> false)
1048
+ else
1049
+ a >= 48 )
1050
+ )
1051
+
1052
+
1053
+ let hash_number_as_i32_exn
1054
+ ( x : string) : int32 =
1055
+ Int32.of_string x
1056
+
1057
+
1058
+ let first_marshal_char (x : string) =
1059
+ x <> "" &&
1060
+ ( String.unsafe_get x 0 = '\132')
1061
+
1062
+ end
1063
+ module Ext_string_array : sig
1064
+ #1 "ext_string_array.mli"
1065
+ (* Copyright (C) 2020 - Present Authors of ReScript
1066
+ *
1067
+ * This program is free software: you can redistribute it and/or modify
1068
+ * it under the terms of the GNU Lesser General Public License as published by
1069
+ * the Free Software Foundation, either version 3 of the License, or
1070
+ * (at your option) any later version.
1071
+ *
1072
+ * In addition to the permissions granted to you by the LGPL, you may combine
1073
+ * or link a "work that uses the Library" with a publicly distributed version
1074
+ * of this file to produce a combined library or application, then distribute
1075
+ * that combined work under the terms of your choosing, with no requirement
1076
+ * to comply with the obligations normally placed on you by section 4 of the
1077
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1078
+ * should you choose to use a later version).
1079
+ *
1080
+ * This program is distributed in the hope that it will be useful,
1081
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1082
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1083
+ * GNU Lesser General Public License for more details.
1084
+ *
1085
+ * You should have received a copy of the GNU Lesser General Public License
1086
+ * along with this program; if not, write to the Free Software
1087
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1088
+
1089
+ val cmp : string -> string -> int
1090
+
1091
+ val find_sorted : string array -> string -> int option
1092
+
1093
+ val find_sorted_assoc : (string * 'a) array -> string -> 'a option
1094
+
1095
+ end = struct
1096
+ #1 "ext_string_array.ml"
1097
+ (* Copyright (C) 2020 - Present Hongbo Zhang, Authors of ReScript
1098
+ *
1099
+ * This program is free software: you can redistribute it and/or modify
1100
+ * it under the terms of the GNU Lesser General Public License as published by
1101
+ * the Free Software Foundation, either version 3 of the License, or
1102
+ * (at your option) any later version.
1103
+ *
1104
+ * In addition to the permissions granted to you by the LGPL, you may combine
1105
+ * or link a "work that uses the Library" with a publicly distributed version
1106
+ * of this file to produce a combined library or application, then distribute
1107
+ * that combined work under the terms of your choosing, with no requirement
1108
+ * to comply with the obligations normally placed on you by section 4 of the
1109
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1110
+ * should you choose to use a later version).
1111
+ *
1112
+ * This program is distributed in the hope that it will be useful,
1113
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1114
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1115
+ * GNU Lesser General Public License for more details.
1116
+ *
1117
+ * You should have received a copy of the GNU Lesser General Public License
1118
+ * along with this program; if not, write to the Free Software
1119
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1120
+
1121
+ (* Invariant: the same as encoding Map_string.compare_key *)
1122
+ let cmp = Ext_string.compare
1123
+
1124
+ let rec binarySearchAux (arr : string array) (lo : int) (hi : int)
1125
+ (key : string) : _ option =
1126
+ let mid = (lo + hi) / 2 in
1127
+ let midVal = Array.unsafe_get arr mid in
1128
+ let c = cmp key midVal in
1129
+ if c = 0 then Some mid
1130
+ else if c < 0 then
1131
+ (* a[lo] =< key < a[mid] <= a[hi] *)
1132
+ if hi = mid then
1133
+ let loVal = Array.unsafe_get arr lo in
1134
+ if loVal = key then Some lo else None
1135
+ else binarySearchAux arr lo mid key
1136
+ else if (* a[lo] =< a[mid] < key <= a[hi] *)
1137
+ lo = mid then
1138
+ let hiVal = Array.unsafe_get arr hi in
1139
+ if hiVal = key then Some hi else None
1140
+ else binarySearchAux arr mid hi key
1141
+
1142
+ let find_sorted sorted key : int option =
1143
+ let len = Array.length sorted in
1144
+ if len = 0 then None
1145
+ else
1146
+ let lo = Array.unsafe_get sorted 0 in
1147
+ let c = cmp key lo in
1148
+ if c < 0 then None
1149
+ else
1150
+ let hi = Array.unsafe_get sorted (len - 1) in
1151
+ let c2 = cmp key hi in
1152
+ if c2 > 0 then None else binarySearchAux sorted 0 (len - 1) key
1153
+
1154
+ let rec binarySearchAssoc (arr : (string * _) array) (lo : int) (hi : int)
1155
+ (key : string) : _ option =
1156
+ let mid = (lo + hi) / 2 in
1157
+ let midVal = Array.unsafe_get arr mid in
1158
+ let c = cmp key (fst midVal) in
1159
+ if c = 0 then Some (snd midVal)
1160
+ else if c < 0 then
1161
+ (* a[lo] =< key < a[mid] <= a[hi] *)
1162
+ if hi = mid then
1163
+ let loVal = Array.unsafe_get arr lo in
1164
+ if fst loVal = key then Some (snd loVal) else None
1165
+ else binarySearchAssoc arr lo mid key
1166
+ else if (* a[lo] =< a[mid] < key <= a[hi] *)
1167
+ lo = mid then
1168
+ let hiVal = Array.unsafe_get arr hi in
1169
+ if fst hiVal = key then Some (snd hiVal) else None
1170
+ else binarySearchAssoc arr mid hi key
1171
+
1172
+ let find_sorted_assoc (type a) (sorted : (string * a) array) (key : string) :
1173
+ a option =
1174
+ let len = Array.length sorted in
1175
+ if len = 0 then None
1176
+ else
1177
+ let lo = Array.unsafe_get sorted 0 in
1178
+ let c = cmp key (fst lo) in
1179
+ if c < 0 then None
1180
+ else
1181
+ let hi = Array.unsafe_get sorted (len - 1) in
1182
+ let c2 = cmp key (fst hi) in
1183
+ if c2 > 0 then None else binarySearchAssoc sorted 0 (len - 1) key
1184
+
1185
+ end
1186
+ module Literals
1187
+ = struct
1188
+ #1 "literals.ml"
1189
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
1190
+ *
1191
+ * This program is free software: you can redistribute it and/or modify
1192
+ * it under the terms of the GNU Lesser General Public License as published by
1193
+ * the Free Software Foundation, either version 3 of the License, or
1194
+ * (at your option) any later version.
1195
+ *
1196
+ * In addition to the permissions granted to you by the LGPL, you may combine
1197
+ * or link a "work that uses the Library" with a publicly distributed version
1198
+ * of this file to produce a combined library or application, then distribute
1199
+ * that combined work under the terms of your choosing, with no requirement
1200
+ * to comply with the obligations normally placed on you by section 4 of the
1201
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1202
+ * should you choose to use a later version).
1203
+ *
1204
+ * This program is distributed in the hope that it will be useful,
1205
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1206
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1207
+ * GNU Lesser General Public License for more details.
1208
+ *
1209
+ * You should have received a copy of the GNU Lesser General Public License
1210
+ * along with this program; if not, write to the Free Software
1211
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1212
+
1213
+ let js_array_ctor = "Array"
1214
+
1215
+ let js_type_number = "number"
1216
+
1217
+ let js_type_string = "string"
1218
+
1219
+ let js_type_object = "object"
1220
+
1221
+ let js_type_boolean = "boolean"
1222
+
1223
+ let js_undefined = "undefined"
1224
+
1225
+ let js_prop_length = "length"
1226
+
1227
+ let prim = "prim"
1228
+
1229
+ let param = "param"
1230
+
1231
+ let partial_arg = "partial_arg"
1232
+
1233
+ let tmp = "tmp"
1234
+
1235
+ let create = "create" (* {!Caml_exceptions.create}*)
1236
+
1237
+ let runtime = "runtime" (* runtime directory *)
1238
+
1239
+ let stdlib = "stdlib"
1240
+
1241
+ let imul = "imul" (* signed int32 mul *)
1242
+
1243
+ let setter_suffix = "#="
1244
+
1245
+ let setter_suffix_len = String.length setter_suffix
1246
+
1247
+ let debugger = "debugger"
1248
+
1249
+ let fn_run = "fn_run"
1250
+
1251
+ let method_run = "method_run"
1252
+
1253
+ let fn_method = "fn_method"
1254
+
1255
+ let fn_mk = "fn_mk"
1256
+ (*let js_fn_runmethod = "js_fn_runmethod"*)
1257
+
1258
+ (** nodejs *)
1259
+ let node_modules = "node_modules"
1260
+
1261
+ let node_modules_length = String.length "node_modules"
1262
+
1263
+ let package_json = "package.json"
1264
+
1265
+ let bsconfig_json = "bsconfig.json"
1266
+
1267
+ let build_ninja = "build.ninja"
1268
+
1269
+ (* Name of the library file created for each external dependency. *)
1270
+ let library_file = "lib"
1271
+
1272
+ let suffix_a = ".a"
1273
+
1274
+ let suffix_cmj = ".cmj"
1275
+
1276
+ let suffix_cmo = ".cmo"
1277
+
1278
+ let suffix_cma = ".cma"
1279
+
1280
+ let suffix_cmi = ".cmi"
1281
+
1282
+ let suffix_cmx = ".cmx"
1283
+
1284
+ let suffix_cmxa = ".cmxa"
1285
+
1286
+ let suffix_mll = ".mll"
1287
+
1288
+ let suffix_ml = ".ml"
1289
+
1290
+ let suffix_mli = ".mli"
1291
+
1292
+ let suffix_re = ".re"
1293
+
1294
+ let suffix_rei = ".rei"
1295
+
1296
+ let suffix_res = ".res"
1297
+
1298
+ let suffix_resi = ".resi"
1299
+
1300
+ let suffix_mlmap = ".mlmap"
1301
+
1302
+ let suffix_cmt = ".cmt"
1303
+
1304
+ let suffix_cmti = ".cmti"
1305
+
1306
+ let suffix_ast = ".ast"
1307
+
1308
+ let suffix_iast = ".iast"
1309
+
1310
+ let suffix_d = ".d"
1311
+
1312
+ let suffix_js = ".js"
1313
+
1314
+ let suffix_bs_js = ".bs.js"
1315
+
1316
+ let suffix_mjs = ".mjs"
1317
+
1318
+ let suffix_cjs = ".cjs"
1319
+
1320
+ let suffix_gen_js = ".gen.js"
1321
+
1322
+ let suffix_gen_tsx = ".gen.tsx"
1323
+
1324
+ let commonjs = "commonjs"
1325
+
1326
+ let es6 = "es6"
1327
+
1328
+ let es6_global = "es6-global"
1329
+
1330
+ let unused_attribute = "Unused attribute "
1331
+
1332
+ (** Used when produce node compatible paths *)
1333
+ let node_sep = "/"
1334
+
1335
+ let node_parent = ".."
1336
+
1337
+ let node_current = "."
1338
+
1339
+ let gentype_import = "genType.import"
1340
+
1341
+ let bsbuild_cache = ".bsbuild"
1342
+
1343
+ let sourcedirs_meta = ".sourcedirs.json"
1344
+
1345
+ (* Note the build system should check the validity of filenames
1346
+ espeically, it should not contain '-'
1347
+ *)
1348
+ let ns_sep_char = '-'
1349
+
1350
+ let ns_sep = "-"
1351
+
1352
+ let exception_id = "RE_EXN_ID"
1353
+
1354
+ let polyvar_hash = "NAME"
1355
+
1356
+ let polyvar_value = "VAL"
1357
+
1358
+ let cons = "::"
1359
+
1360
+ let hd = "hd"
1361
+
1362
+ let tl = "tl"
1363
+
1364
+ let lazy_done = "LAZY_DONE"
1365
+
1366
+ let lazy_val = "VAL"
1367
+
1368
+ let pure = "@__PURE__"
1369
+
1370
+ end
1371
+ module Bsb_db_decode : sig
1372
+ #1 "bsb_db_decode.mli"
1373
+ (* Copyright (C) 2019 - Present Authors of ReScript
1374
+ *
1375
+ * This program is free software: you can redistribute it and/or modify
1376
+ * it under the terms of the GNU Lesser General Public License as published by
1377
+ * the Free Software Foundation, either version 3 of the License, or
1378
+ * (at your option) any later version.
1379
+ *
1380
+ * In addition to the permissions granted to you by the LGPL, you may combine
1381
+ * or link a "work that uses the Library" with a publicly distributed version
1382
+ * of this file to produce a combined library or application, then distribute
1383
+ * that combined work under the terms of your choosing, with no requirement
1384
+ * to comply with the obligations normally placed on you by section 4 of the
1385
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1386
+ * should you choose to use a later version).
1387
+ *
1388
+ * This program is distributed in the hope that it will be useful,
1389
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1390
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1391
+ * GNU Lesser General Public License for more details.
1392
+ *
1393
+ * You should have received a copy of the GNU Lesser General Public License
1394
+ * along with this program; if not, write to the Free Software
1395
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1396
+
1397
+ type group = private
1398
+ | Dummy
1399
+ | Group of {
1400
+ modules : string array;
1401
+ dir_length : int;
1402
+ dir_info_offset : int;
1403
+ module_info_offset : int;
1404
+ }
1405
+
1406
+ type t = {
1407
+ lib : group;
1408
+ dev : group;
1409
+ content : string; (* string is whole content*)
1410
+ }
1411
+
1412
+ val read_build_cache : dir:string -> t
1413
+
1414
+ type module_info = { case : bool; (* Bsb_db.case*) dir_name : string }
1415
+
1416
+ val find :
1417
+ t ->
1418
+ (* contains global info *)
1419
+ string ->
1420
+ (* module name *)
1421
+ bool ->
1422
+ (* more likely to be zero *)
1423
+ module_info option
1424
+
1425
+ val decode : string -> t
1426
+
1427
+ end = struct
1428
+ #1 "bsb_db_decode.ml"
1429
+ (* Copyright (C) 2019 - Present Hongbo Zhang, Authors of ReScript
1430
+ *
1431
+ * This program is free software: you can redistribute it and/or modify
1432
+ * it under the terms of the GNU Lesser General Public License as published by
1433
+ * the Free Software Foundation, either version 3 of the License, or
1434
+ * (at your option) any later version.
1435
+ *
1436
+ * In addition to the permissions granted to you by the LGPL, you may combine
1437
+ * or link a "work that uses the Library" with a publicly distributed version
1438
+ * of this file to produce a combined library or application, then distribute
1439
+ * that combined work under the terms of your choosing, with no requirement
1440
+ * to comply with the obligations normally placed on you by section 4 of the
1441
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1442
+ * should you choose to use a later version).
1443
+ *
1444
+ * This program is distributed in the hope that it will be useful,
1445
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1446
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1447
+ * GNU Lesser General Public License for more details.
1448
+ *
1449
+ * You should have received a copy of the GNU Lesser General Public License
1450
+ * along with this program; if not, write to the Free Software
1451
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1452
+
1453
+ let bsbuild_cache = Literals.bsbuild_cache
1454
+
1455
+ type group =
1456
+ | Dummy
1457
+ | Group of {
1458
+ modules : string array;
1459
+ dir_length : int;
1460
+ dir_info_offset : int;
1461
+ module_info_offset : int;
1462
+ }
1463
+
1464
+ type t = {
1465
+ lib : group;
1466
+ dev : group;
1467
+ content : string; (* string is whole content*)
1468
+ }
1469
+
1470
+ type cursor = int ref
1471
+
1472
+ (*TODO: special case when module_count is zero *)
1473
+ let rec decode (x : string) : t =
1474
+ let (offset : cursor) = ref 0 in
1475
+ let lib = decode_single x offset in
1476
+ let dev = decode_single x offset in
1477
+ { lib; dev; content = x }
1478
+
1479
+ and decode_single (x : string) (offset : cursor) : group =
1480
+ let module_number = Ext_pervasives.parse_nat_of_string x offset in
1481
+ incr offset;
1482
+ if module_number <> 0 then (
1483
+ let modules = decode_modules x offset module_number in
1484
+ let dir_info_offset = !offset in
1485
+ let module_info_offset = String.index_from x dir_info_offset '\n' + 1 in
1486
+ let dir_length = Char.code x.[module_info_offset] - 48 (* Char.code '0'*) in
1487
+ offset := module_info_offset + 1 + (dir_length * module_number) + 1;
1488
+ Group { modules; dir_info_offset; module_info_offset; dir_length })
1489
+ else Dummy
1490
+
1491
+ and decode_modules (x : string) (offset : cursor) module_number : string array =
1492
+ let result = Array.make module_number "" in
1493
+ let last = ref !offset in
1494
+ let cur = ref !offset in
1495
+ let tasks = ref 0 in
1496
+ while !tasks <> module_number do
1497
+ if String.unsafe_get x !cur = '\n' then (
1498
+ let offs = !last in
1499
+ let len = !cur - !last in
1500
+ Array.unsafe_set result !tasks (Ext_string.unsafe_sub x offs len);
1501
+ incr tasks;
1502
+ last := !cur + 1);
1503
+ incr cur
1504
+ done;
1505
+ offset := !cur;
1506
+ result
1507
+
1508
+ (* TODO: shall we check the consistency of digest *)
1509
+ let read_build_cache ~dir : t =
1510
+ let all_content = Ext_io.load_file (Filename.concat dir bsbuild_cache) in
1511
+ decode all_content
1512
+
1513
+ type module_info = { case : bool; (* which is Bsb_db.case*) dir_name : string }
1514
+
1515
+ let find_opt ({ content = whole } as db : t) lib (key : string) :
1516
+ module_info option =
1517
+ match if lib then db.lib else db.dev with
1518
+ | Dummy -> None
1519
+ | Group ({ modules } as group) -> (
1520
+ let i = Ext_string_array.find_sorted modules key in
1521
+ match i with
1522
+ | None -> None
1523
+ | Some count ->
1524
+ let encode_len = group.dir_length in
1525
+ let index =
1526
+ Ext_string.get_1_2_3_4 whole
1527
+ ~off:(group.module_info_offset + 1 + (count * encode_len))
1528
+ encode_len
1529
+ in
1530
+ let case = not (index mod 2 = 0) in
1531
+ let ith = index lsr 1 in
1532
+ let dir_name_start =
1533
+ if ith = 0 then group.dir_info_offset
1534
+ else Ext_string.index_count whole group.dir_info_offset '\t' ith + 1
1535
+ in
1536
+ let dir_name_finish = String.index_from whole dir_name_start '\t' in
1537
+ Some
1538
+ {
1539
+ case;
1540
+ dir_name =
1541
+ String.sub whole dir_name_start
1542
+ (dir_name_finish - dir_name_start);
1543
+ })
1544
+
1545
+ let find db dependent_module is_not_lib_dir =
1546
+ let opt = find_opt db true dependent_module in
1547
+ match opt with
1548
+ | Some _ -> opt
1549
+ | None -> if is_not_lib_dir then find_opt db false dependent_module else None
1550
+
1551
+ end
1552
+ module Ext_buffer : sig
1553
+ #1 "ext_buffer.mli"
1554
+ (***********************************************************************)
1555
+ (* *)
1556
+ (* OCaml *)
1557
+ (* *)
1558
+ (* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
1559
+ (* *)
1560
+ (* Copyright 1999 Institut National de Recherche en Informatique et *)
1561
+ (* en Automatique. All rights reserved. This file is distributed *)
1562
+ (* under the terms of the GNU Library General Public License, with *)
1563
+ (* the special exception on linking described in file ../LICENSE. *)
1564
+ (* *)
1565
+ (***********************************************************************)
1566
+
1567
+ (** Extensible buffers.
1568
+
1569
+ This module implements buffers that automatically expand
1570
+ as necessary. It provides accumulative concatenation of strings
1571
+ in quasi-linear time (instead of quadratic time when strings are
1572
+ concatenated pairwise).
1573
+ *)
1574
+
1575
+ (* ReScript customization: customized for efficient digest *)
1576
+
1577
+ type t
1578
+ (** The abstract type of buffers. *)
1579
+
1580
+ val create : int -> t
1581
+ (** [create n] returns a fresh buffer, initially empty.
1582
+ The [n] parameter is the initial size of the internal byte sequence
1583
+ that holds the buffer contents. That byte sequence is automatically
1584
+ reallocated when more than [n] characters are stored in the buffer,
1585
+ but shrinks back to [n] characters when [reset] is called.
1586
+ For best performance, [n] should be of the same order of magnitude
1587
+ as the number of characters that are expected to be stored in
1588
+ the buffer (for instance, 80 for a buffer that holds one output
1589
+ line). Nothing bad will happen if the buffer grows beyond that
1590
+ limit, however. In doubt, take [n = 16] for instance.
1591
+ If [n] is not between 1 and {!Sys.max_string_length}, it will
1592
+ be clipped to that interval. *)
1593
+
1594
+ val contents : t -> string
1595
+ (** Return a copy of the current contents of the buffer.
1596
+ The buffer itself is unchanged. *)
1597
+
1598
+ val length : t -> int
1599
+ (** Return the number of characters currently contained in the buffer. *)
1600
+
1601
+ val is_empty : t -> bool
1602
+
1603
+ val clear : t -> unit
1604
+ (** Empty the buffer. *)
1605
+
1606
+ val add_char : t -> char -> unit
1607
+ [@@inline]
1608
+ (** [add_char b c] appends the character [c] at the end of the buffer [b]. *)
1609
+
1610
+ val add_string : t -> string -> unit
1611
+ (** [add_string b s] appends the string [s] at the end of the buffer [b]. *)
1612
+
1613
+ (* val add_bytes : t -> bytes -> unit *)
1614
+ (** [add_string b s] appends the string [s] at the end of the buffer [b].
1615
+ @since 4.02 *)
1616
+
1617
+ (* val add_substring : t -> string -> int -> int -> unit *)
1618
+ (** [add_substring b s ofs len] takes [len] characters from offset
1619
+ [ofs] in string [s] and appends them at the end of the buffer [b]. *)
1620
+
1621
+ (* val add_subbytes : t -> bytes -> int -> int -> unit *)
1622
+ (** [add_substring b s ofs len] takes [len] characters from offset
1623
+ [ofs] in byte sequence [s] and appends them at the end of the buffer [b].
1624
+ @since 4.02 *)
1625
+
1626
+ (* val add_buffer : t -> t -> unit *)
1627
+ (** [add_buffer b1 b2] appends the current contents of buffer [b2]
1628
+ at the end of buffer [b1]. [b2] is not modified. *)
1629
+
1630
+ (* val add_channel : t -> in_channel -> int -> unit *)
1631
+ (** [add_channel b ic n] reads exactly [n] character from the
1632
+ input channel [ic] and stores them at the end of buffer [b].
1633
+ Raise [End_of_file] if the channel contains fewer than [n]
1634
+ characters. *)
1635
+
1636
+ val output_buffer : out_channel -> t -> unit
1637
+ (** [output_buffer oc b] writes the current contents of buffer [b]
1638
+ on the output channel [oc]. *)
1639
+
1640
+ val digest : t -> Digest.t
1641
+
1642
+ val not_equal : t -> string -> bool
1643
+
1644
+ val add_int_1 : t -> int -> unit
1645
+
1646
+ val add_int_2 : t -> int -> unit
1647
+
1648
+ val add_int_3 : t -> int -> unit
1649
+
1650
+ val add_int_4 : t -> int -> unit
1651
+
1652
+ val add_string_char : t -> string -> char -> unit
1653
+
1654
+ val add_ninja_prefix_var : t -> string -> unit
1655
+
1656
+ val add_char_string : t -> char -> string -> unit
1657
+
1658
+ end = struct
1659
+ #1 "ext_buffer.ml"
1660
+ (**************************************************************************)
1661
+ (* *)
1662
+ (* OCaml *)
1663
+ (* *)
1664
+ (* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
1665
+ (* *)
1666
+ (* Copyright 1999 Institut National de Recherche en Informatique et *)
1667
+ (* en Automatique. *)
1668
+ (* *)
1669
+ (* All rights reserved. This file is distributed under the terms of *)
1670
+ (* the GNU Lesser General Public License version 2.1, with the *)
1671
+ (* special exception on linking described in the file LICENSE. *)
1672
+ (* *)
1673
+ (**************************************************************************)
1674
+
1675
+ (* Extensible buffers *)
1676
+
1677
+ type t = {
1678
+ mutable buffer : bytes;
1679
+ mutable position : int;
1680
+ mutable length : int;
1681
+ }
1682
+
1683
+ let create n =
1684
+ let n = if n < 1 then 1 else n in
1685
+ let s = Bytes.create n in
1686
+ { buffer = s; position = 0; length = n }
1687
+
1688
+ let contents b = Bytes.sub_string b.buffer 0 b.position
1689
+ (* let to_bytes b = Bytes.sub b.buffer 0 b.position *)
1690
+
1691
+ (* let sub b ofs len =
1692
+ if ofs < 0 || len < 0 || ofs > b.position - len
1693
+ then invalid_arg "Ext_buffer.sub"
1694
+ else Bytes.sub_string b.buffer ofs len *)
1695
+
1696
+ (* let blit src srcoff dst dstoff len =
1697
+ if len < 0 || srcoff < 0 || srcoff > src.position - len
1698
+ || dstoff < 0 || dstoff > (Bytes.length dst) - len
1699
+ then invalid_arg "Ext_buffer.blit"
1700
+ else
1701
+ Bytes.unsafe_blit src.buffer srcoff dst dstoff len *)
1702
+
1703
+ let length b = b.position
1704
+
1705
+ let is_empty b = b.position = 0
1706
+
1707
+ let clear b = b.position <- 0
1708
+
1709
+ (* let reset b =
1710
+ b.position <- 0; b.buffer <- b.initial_buffer;
1711
+ b.length <- Bytes.length b.buffer *)
1712
+
1713
+ let resize b more =
1714
+ let len = b.length in
1715
+ let new_len = ref len in
1716
+ while b.position + more > !new_len do
1717
+ new_len := 2 * !new_len
1718
+ done;
1719
+ let new_buffer = Bytes.create !new_len in
1720
+ (* PR#6148: let's keep using [blit] rather than [unsafe_blit] in
1721
+ this tricky function that is slow anyway. *)
1722
+ Bytes.blit b.buffer 0 new_buffer 0 b.position;
1723
+ b.buffer <- new_buffer;
1724
+ b.length <- !new_len;
1725
+ assert (b.position + more <= b.length)
1726
+
1727
+ let[@inline] add_char b c =
1728
+ let pos = b.position in
1729
+ if pos >= b.length then resize b 1;
1730
+ Bytes.unsafe_set b.buffer pos c;
1731
+ b.position <- pos + 1
1732
+
1733
+ (* let add_substring b s offset len =
1734
+ if offset < 0 || len < 0 || offset > String.length s - len
1735
+ then invalid_arg "Ext_buffer.add_substring/add_subbytes";
1736
+ let new_position = b.position + len in
1737
+ if new_position > b.length then resize b len;
1738
+ Ext_bytes.unsafe_blit_string s offset b.buffer b.position len;
1739
+ b.position <- new_position *)
1740
+
1741
+ (* let add_subbytes b s offset len =
1742
+ add_substring b (Bytes.unsafe_to_string s) offset len *)
1743
+
1744
+ let add_string b s =
1745
+ let len = String.length s in
1746
+ let new_position = b.position + len in
1747
+ if new_position > b.length then resize b len;
1748
+ Ext_bytes.unsafe_blit_string s 0 b.buffer b.position len;
1749
+ b.position <- new_position
1750
+
1751
+ (* TODO: micro-optimzie *)
1752
+ let add_string_char b s c =
1753
+ let s_len = String.length s in
1754
+ let len = s_len + 1 in
1755
+ let new_position = b.position + len in
1756
+ if new_position > b.length then resize b len;
1757
+ let b_buffer = b.buffer in
1758
+ Ext_bytes.unsafe_blit_string s 0 b_buffer b.position s_len;
1759
+ Bytes.unsafe_set b_buffer (new_position - 1) c;
1760
+ b.position <- new_position
1761
+
1762
+ let add_char_string b c s =
1763
+ let s_len = String.length s in
1764
+ let len = s_len + 1 in
1765
+ let new_position = b.position + len in
1766
+ if new_position > b.length then resize b len;
1767
+ let b_buffer = b.buffer in
1768
+ let b_position = b.position in
1769
+ Bytes.unsafe_set b_buffer b_position c;
1770
+ Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len;
1771
+ b.position <- new_position
1772
+
1773
+ (* equivalent to add_char " "; add_char "$"; add_string s *)
1774
+ let add_ninja_prefix_var b s =
1775
+ let s_len = String.length s in
1776
+ let len = s_len + 2 in
1777
+ let new_position = b.position + len in
1778
+ if new_position > b.length then resize b len;
1779
+ let b_buffer = b.buffer in
1780
+ let b_position = b.position in
1781
+ Bytes.unsafe_set b_buffer b_position ' ';
1782
+ Bytes.unsafe_set b_buffer (b_position + 1) '$';
1783
+ Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
1784
+ b.position <- new_position
1785
+
1786
+ (* let add_bytes b s = add_string b (Bytes.unsafe_to_string s)
1787
+
1788
+ let add_buffer b bs =
1789
+ add_subbytes b bs.buffer 0 bs.position *)
1790
+
1791
+ (* let add_channel b ic len =
1792
+ if len < 0
1793
+ || len > Sys.max_string_length
1794
+ then (* PR#5004 *)
1795
+ invalid_arg "Ext_buffer.add_channel";
1796
+ if b.position + len > b.length then resize b len;
1797
+ really_input ic b.buffer b.position len;
1798
+ b.position <- b.position + len *)
1799
+
1800
+ let output_buffer oc b = output oc b.buffer 0 b.position
1801
+
1802
+ external unsafe_string : bytes -> int -> int -> Digest.t = "caml_md5_string"
1803
+
1804
+ let digest b = unsafe_string b.buffer 0 b.position
1805
+
1806
+ let rec not_equal_aux (b : bytes) (s : string) i len =
1807
+ if i >= len then false
1808
+ else
1809
+ Bytes.unsafe_get b i <> String.unsafe_get s i
1810
+ || not_equal_aux b s (i + 1) len
1811
+
1812
+ (** avoid a large copy *)
1813
+ let not_equal (b : t) (s : string) =
1814
+ let b_len = b.position in
1815
+ let s_len = String.length s in
1816
+ b_len <> s_len || not_equal_aux b.buffer s 0 s_len
1817
+
1818
+ (**
1819
+ It could be one byte, two bytes, three bytes and four bytes
1820
+ TODO: inline for better performance
1821
+ *)
1822
+ let add_int_1 (b : t) (x : int) =
1823
+ let c = Char.unsafe_chr (x land 0xff) in
1824
+ let pos = b.position in
1825
+ if pos >= b.length then resize b 1;
1826
+ Bytes.unsafe_set b.buffer pos c;
1827
+ b.position <- pos + 1
1828
+
1829
+ let add_int_2 (b : t) (x : int) =
1830
+ let c1 = Char.unsafe_chr (x land 0xff) in
1831
+ let c2 = Char.unsafe_chr ((x lsr 8) land 0xff) in
1832
+ let pos = b.position in
1833
+ if pos + 1 >= b.length then resize b 2;
1834
+ let b_buffer = b.buffer in
1835
+ Bytes.unsafe_set b_buffer pos c1;
1836
+ Bytes.unsafe_set b_buffer (pos + 1) c2;
1837
+ b.position <- pos + 2
1838
+
1839
+ let add_int_3 (b : t) (x : int) =
1840
+ let c1 = Char.unsafe_chr (x land 0xff) in
1841
+ let c2 = Char.unsafe_chr ((x lsr 8) land 0xff) in
1842
+ let c3 = Char.unsafe_chr ((x lsr 16) land 0xff) in
1843
+ let pos = b.position in
1844
+ if pos + 2 >= b.length then resize b 3;
1845
+ let b_buffer = b.buffer in
1846
+ Bytes.unsafe_set b_buffer pos c1;
1847
+ Bytes.unsafe_set b_buffer (pos + 1) c2;
1848
+ Bytes.unsafe_set b_buffer (pos + 2) c3;
1849
+ b.position <- pos + 3
1850
+
1851
+ let add_int_4 (b : t) (x : int) =
1852
+ let c1 = Char.unsafe_chr (x land 0xff) in
1853
+ let c2 = Char.unsafe_chr ((x lsr 8) land 0xff) in
1854
+ let c3 = Char.unsafe_chr ((x lsr 16) land 0xff) in
1855
+ let c4 = Char.unsafe_chr ((x lsr 24) land 0xff) in
1856
+ let pos = b.position in
1857
+ if pos + 3 >= b.length then resize b 4;
1858
+ let b_buffer = b.buffer in
1859
+ Bytes.unsafe_set b_buffer pos c1;
1860
+ Bytes.unsafe_set b_buffer (pos + 1) c2;
1861
+ Bytes.unsafe_set b_buffer (pos + 2) c3;
1862
+ Bytes.unsafe_set b_buffer (pos + 3) c4;
1863
+ b.position <- pos + 4
1864
+
1865
+ end
1866
+ module Ext_filename : sig
1867
+ #1 "ext_filename.mli"
1868
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
1869
+ *
1870
+ * This program is free software: you can redistribute it and/or modify
1871
+ * it under the terms of the GNU Lesser General Public License as published by
1872
+ * the Free Software Foundation, either version 3 of the License, or
1873
+ * (at your option) any later version.
1874
+ *
1875
+ * In addition to the permissions granted to you by the LGPL, you may combine
1876
+ * or link a "work that uses the Library" with a publicly distributed version
1877
+ * of this file to produce a combined library or application, then distribute
1878
+ * that combined work under the terms of your choosing, with no requirement
1879
+ * to comply with the obligations normally placed on you by section 4 of the
1880
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1881
+ * should you choose to use a later version).
1882
+ *
1883
+ * This program is distributed in the hope that it will be useful,
1884
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1885
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1886
+ * GNU Lesser General Public License for more details.
1887
+ *
1888
+ * You should have received a copy of the GNU Lesser General Public License
1889
+ * along with this program; if not, write to the Free Software
1890
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1891
+
1892
+ (* TODO:
1893
+ Change the module name, this code is not really an extension of the standard
1894
+ library but rather specific to JS Module name convention.
1895
+ *)
1896
+
1897
+ (** An extension module to calculate relative path follow node/npm style.
1898
+ TODO : this short name will have to change upon renaming the file.
1899
+ *)
1900
+
1901
+ val is_dir_sep : char -> bool
1902
+
1903
+ val maybe_quote : string -> string
1904
+
1905
+ val chop_extension_maybe : string -> string
1906
+
1907
+ (* return an empty string if no extension found *)
1908
+ val get_extension_maybe : string -> string
1909
+
1910
+ val new_extension : string -> string -> string
1911
+
1912
+ val chop_all_extensions_maybe : string -> string
1913
+
1914
+ (* OCaml specific abstraction*)
1915
+ val module_name : string -> string
1916
+
1917
+ type module_info = { module_name : string; case : bool }
1918
+
1919
+ val as_module : basename:string -> module_info option
1920
+
1921
+ end = struct
1922
+ #1 "ext_filename.ml"
1923
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
1924
+ *
1925
+ * This program is free software: you can redistribute it and/or modify
1926
+ * it under the terms of the GNU Lesser General Public License as published by
1927
+ * the Free Software Foundation, either version 3 of the License, or
1928
+ * (at your option) any later version.
1929
+ *
1930
+ * In addition to the permissions granted to you by the LGPL, you may combine
1931
+ * or link a "work that uses the Library" with a publicly distributed version
1932
+ * of this file to produce a combined library or application, then distribute
1933
+ * that combined work under the terms of your choosing, with no requirement
1934
+ * to comply with the obligations normally placed on you by section 4 of the
1935
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
1936
+ * should you choose to use a later version).
1937
+ *
1938
+ * This program is distributed in the hope that it will be useful,
1939
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1940
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1941
+ * GNU Lesser General Public License for more details.
1942
+ *
1943
+ * You should have received a copy of the GNU Lesser General Public License
1944
+ * along with this program; if not, write to the Free Software
1945
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1946
+
1947
+ let is_dir_sep_unix c = c = '/'
1948
+
1949
+ let is_dir_sep_win_cygwin c = c = '/' || c = '\\' || c = ':'
1950
+
1951
+ let is_dir_sep = if Sys.unix then is_dir_sep_unix else is_dir_sep_win_cygwin
1952
+
1953
+ (* reference ninja.cc IsKnownShellSafeCharacter *)
1954
+ let maybe_quote (s : string) =
1955
+ let noneed_quote =
1956
+ Ext_string.for_all s (function
1957
+ | '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '_' | '+' | '-' | '.' | '/' | '@'
1958
+ ->
1959
+ true
1960
+ | _ -> false)
1961
+ in
1962
+ if noneed_quote then s else Filename.quote s
1963
+
1964
+ let chop_extension_maybe name =
1965
+ let rec search_dot i =
1966
+ if i < 0 || is_dir_sep (String.unsafe_get name i) then name
1967
+ else if String.unsafe_get name i = '.' then String.sub name 0 i
1968
+ else search_dot (i - 1)
1969
+ in
1970
+ search_dot (String.length name - 1)
1971
+
1972
+ let get_extension_maybe name =
1973
+ let name_len = String.length name in
1974
+ let rec search_dot name i name_len =
1975
+ if i < 0 || is_dir_sep (String.unsafe_get name i) then ""
1976
+ else if String.unsafe_get name i = '.' then String.sub name i (name_len - i)
1977
+ else search_dot name (i - 1) name_len
1978
+ in
1979
+ search_dot name (name_len - 1) name_len
1980
+
1981
+ let chop_all_extensions_maybe name =
1982
+ let rec search_dot i last =
1983
+ if i < 0 || is_dir_sep (String.unsafe_get name i) then
1984
+ match last with None -> name | Some i -> String.sub name 0 i
1985
+ else if String.unsafe_get name i = '.' then search_dot (i - 1) (Some i)
1986
+ else search_dot (i - 1) last
1987
+ in
1988
+ search_dot (String.length name - 1) None
1989
+
1990
+ let new_extension name (ext : string) =
1991
+ let rec search_dot name i ext =
1992
+ if i < 0 || is_dir_sep (String.unsafe_get name i) then name ^ ext
1993
+ else if String.unsafe_get name i = '.' then (
1994
+ let ext_len = String.length ext in
1995
+ let buf = Bytes.create (i + ext_len) in
1996
+ Bytes.blit_string name 0 buf 0 i;
1997
+ Bytes.blit_string ext 0 buf i ext_len;
1998
+ Bytes.unsafe_to_string buf)
1999
+ else search_dot name (i - 1) ext
2000
+ in
2001
+ search_dot name (String.length name - 1) ext
2002
+
2003
+ (** TODO: improve efficiency
2004
+ given a path, calcuate its module name
2005
+ Note that `ocamlc.opt -c aa.xx.mli` gives `aa.xx.cmi`
2006
+ we can not strip all extensions, otherwise
2007
+ we can not tell the difference between "x.cpp.ml"
2008
+ and "x.ml"
2009
+ *)
2010
+ let module_name name =
2011
+ let rec search_dot i name =
2012
+ if i < 0 then Ext_string.capitalize_ascii name
2013
+ else if String.unsafe_get name i = '.' then Ext_string.capitalize_sub name i
2014
+ else search_dot (i - 1) name
2015
+ in
2016
+ let name = Filename.basename name in
2017
+ let name_len = String.length name in
2018
+ search_dot (name_len - 1) name
2019
+
2020
+ type module_info = { module_name : string; case : bool }
2021
+
2022
+ let rec valid_module_name_aux name off len =
2023
+ if off >= len then true
2024
+ else
2025
+ let c = String.unsafe_get name off in
2026
+ match c with
2027
+ | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '\'' | '.' | '[' | ']' ->
2028
+ valid_module_name_aux name (off + 1) len
2029
+ | _ -> false
2030
+
2031
+ type state = Invalid | Upper | Lower
2032
+
2033
+ let valid_module_name name len =
2034
+ if len = 0 then Invalid
2035
+ else
2036
+ let c = String.unsafe_get name 0 in
2037
+ match c with
2038
+ | 'A' .. 'Z' -> if valid_module_name_aux name 1 len then Upper else Invalid
2039
+ | 'a' .. 'z' | '0' .. '9' | '_' | '[' | ']' ->
2040
+ if valid_module_name_aux name 1 len then Lower else Invalid
2041
+ | _ -> Invalid
2042
+
2043
+ let as_module ~basename =
2044
+ let rec search_dot i name name_len =
2045
+ if i < 0 then
2046
+ (* Input e.g, [a_b] *)
2047
+ match valid_module_name name name_len with
2048
+ | Invalid -> None
2049
+ | Upper -> Some { module_name = name; case = true }
2050
+ | Lower ->
2051
+ Some { module_name = Ext_string.capitalize_ascii name; case = false }
2052
+ else if String.unsafe_get name i = '.' then
2053
+ (*Input e.g, [A_b] *)
2054
+ match valid_module_name name i with
2055
+ | Invalid -> None
2056
+ | Upper ->
2057
+ Some { module_name = Ext_string.capitalize_sub name i; case = true }
2058
+ | Lower ->
2059
+ Some { module_name = Ext_string.capitalize_sub name i; case = false }
2060
+ else search_dot (i - 1) name name_len
2061
+ in
2062
+ let name_len = String.length basename in
2063
+ search_dot (name_len - 1) basename name_len
2064
+
2065
+ end
2066
+ module Ext_namespace_encode : sig
2067
+ #1 "ext_namespace_encode.mli"
2068
+ (* Copyright (C) 2020- Authors of ReScript
2069
+ *
2070
+ * This program is free software: you can redistribute it and/or modify
2071
+ * it under the terms of the GNU Lesser General Public License as published by
2072
+ * the Free Software Foundation, either version 3 of the License, or
2073
+ * (at your option) any later version.
2074
+ *
2075
+ * In addition to the permissions granted to you by the LGPL, you may combine
2076
+ * or link a "work that uses the Library" with a publicly distributed version
2077
+ * of this file to produce a combined library or application, then distribute
2078
+ * that combined work under the terms of your choosing, with no requirement
2079
+ * to comply with the obligations normally placed on you by section 4 of the
2080
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2081
+ * should you choose to use a later version).
2082
+ *
2083
+ * This program is distributed in the hope that it will be useful,
2084
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2085
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2086
+ * GNU Lesser General Public License for more details.
2087
+ *
2088
+ * You should have received a copy of the GNU Lesser General Public License
2089
+ * along with this program; if not, write to the Free Software
2090
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2091
+
2092
+ val make : ?ns:string -> string -> string
2093
+ (** [make ~ns:"Ns" "a" ]
2094
+ A typical example would return "a-Ns"
2095
+ Note the namespace comes from the output of [namespace_of_package_name]
2096
+ *)
2097
+
2098
+ end = struct
2099
+ #1 "ext_namespace_encode.ml"
2100
+ (* Copyright (C) 2020- Hongbo Zhang, Authors of ReScript
2101
+ *
2102
+ * This program is free software: you can redistribute it and/or modify
2103
+ * it under the terms of the GNU Lesser General Public License as published by
2104
+ * the Free Software Foundation, either version 3 of the License, or
2105
+ * (at your option) any later version.
2106
+ *
2107
+ * In addition to the permissions granted to you by the LGPL, you may combine
2108
+ * or link a "work that uses the Library" with a publicly distributed version
2109
+ * of this file to produce a combined library or application, then distribute
2110
+ * that combined work under the terms of your choosing, with no requirement
2111
+ * to comply with the obligations normally placed on you by section 4 of the
2112
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2113
+ * should you choose to use a later version).
2114
+ *
2115
+ * This program is distributed in the hope that it will be useful,
2116
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2117
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2118
+ * GNU Lesser General Public License for more details.
2119
+ *
2120
+ * You should have received a copy of the GNU Lesser General Public License
2121
+ * along with this program; if not, write to the Free Software
2122
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2123
+
2124
+ let make ?ns cunit =
2125
+ match ns with None -> cunit | Some ns -> cunit ^ Literals.ns_sep ^ ns
2126
+
2127
+ end
2128
+ module Bsb_helper_depfile_gen : sig
2129
+ #1 "bsb_helper_depfile_gen.mli"
2130
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2131
+ *
2132
+ * This program is free software: you can redistribute it and/or modify
2133
+ * it under the terms of the GNU Lesser General Public License as published by
2134
+ * the Free Software Foundation, either version 3 of the License, or
2135
+ * (at your option) any later version.
2136
+ *
2137
+ * In addition to the permissions granted to you by the LGPL, you may combine
2138
+ * or link a "work that uses the Library" with a publicly distributed version
2139
+ * of this file to produce a combined library or application, then distribute
2140
+ * that combined work under the terms of your choosing, with no requirement
2141
+ * to comply with the obligations normally placed on you by section 4 of the
2142
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2143
+ * should you choose to use a later version).
2144
+ *
2145
+ * This program is distributed in the hope that it will be useful,
2146
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2147
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2148
+ * GNU Lesser General Public License for more details.
2149
+ *
2150
+ * You should have received a copy of the GNU Lesser General Public License
2151
+ * along with this program; if not, write to the Free Software
2152
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2153
+
2154
+ val deps_of_channel : in_channel -> string list
2155
+ (** [deps_of_channel ic]
2156
+ given an input_channel dumps all modules it depend on, only used for debugging
2157
+ *)
2158
+
2159
+ val emit_d :
2160
+ bool ->
2161
+ string option ->
2162
+ string ->
2163
+ string ->
2164
+ (* empty string means no mliast *)
2165
+ unit
2166
+
2167
+ end = struct
2168
+ #1 "bsb_helper_depfile_gen.ml"
2169
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2170
+ *
2171
+ * This program is free software: you can redistribute it and/or modify
2172
+ * it under the terms of the GNU Lesser General Public License as published by
2173
+ * the Free Software Foundation, either version 3 of the License, or
2174
+ * (at your option) any later version.
2175
+ *
2176
+ * In addition to the permissions granted to you by the LGPL, you may combine
2177
+ * or link a "work that uses the Library" with a publicly distributed version
2178
+ * of this file to produce a combined library or application, then distribute
2179
+ * that combined work under the terms of your choosing, with no requirement
2180
+ * to comply with the obligations normally placed on you by section 4 of the
2181
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2182
+ * should you choose to use a later version).
2183
+ *
2184
+ * This program is distributed in the hope that it will be useful,
2185
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2186
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2187
+ * GNU Lesser General Public License for more details.
2188
+ *
2189
+ * You should have received a copy of the GNU Lesser General Public License
2190
+ * along with this program; if not, write to the Free Software
2191
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2192
+
2193
+ let dep_lit = " :"
2194
+
2195
+ let write_buf name buf =
2196
+ let oc = open_out_bin name in
2197
+ Ext_buffer.output_buffer oc buf;
2198
+ close_out oc
2199
+
2200
+ (* should be good for small file *)
2201
+ let load_file name (buf : Ext_buffer.t) : unit =
2202
+ let len = Ext_buffer.length buf in
2203
+ let ic = open_in_bin name in
2204
+ let n = in_channel_length ic in
2205
+ if n <> len then (
2206
+ close_in ic;
2207
+ write_buf name buf)
2208
+ else
2209
+ let holder = really_input_string ic n in
2210
+ close_in ic;
2211
+ if Ext_buffer.not_equal buf holder then write_buf name buf
2212
+
2213
+ let write_file name (buf : Ext_buffer.t) =
2214
+ if Sys.file_exists name then load_file name buf else write_buf name buf
2215
+
2216
+ (* return an non-decoded string *)
2217
+ let extract_dep_raw_string (fn : string) : string =
2218
+ let ic = open_in_bin fn in
2219
+ let size = input_binary_int ic in
2220
+ let s = really_input_string ic size in
2221
+ close_in ic;
2222
+ s
2223
+
2224
+ (* Make sure it is the same as {!Binary_ast.magic_sep_char}*)
2225
+ let magic_sep_char = '\n'
2226
+
2227
+ let deps_of_channel (ic : in_channel) : string list =
2228
+ let size = input_binary_int ic in
2229
+ let s = really_input_string ic size in
2230
+ let rec aux (s : string) acc (offset : int) size : string list =
2231
+ if offset < size then
2232
+ let next_tab = String.index_from s offset magic_sep_char in
2233
+ aux s (String.sub s offset (next_tab - offset) :: acc) (next_tab + 1) size
2234
+ else acc
2235
+ in
2236
+ aux s [] 1 size
2237
+
2238
+ (** Please refer to {!Binary_ast} for encoding format, we move it here
2239
+ mostly for cutting the dependency so that [bsb_helper.exe] does
2240
+ not depend on compler-libs
2241
+ *)
2242
+ (* let read_deps (fn : string) : string list =
2243
+ let ic = open_in_bin fn in
2244
+ let v = deps_of_channel ic in
2245
+ close_in ic;
2246
+ v
2247
+ *)
2248
+
2249
+ let output_file (buf : Ext_buffer.t) source namespace =
2250
+ Ext_buffer.add_string buf (Ext_namespace_encode.make ?ns:namespace source)
2251
+
2252
+ (** for rescript artifacts
2253
+ [lhs_suffix] is [.cmj]
2254
+ [rhs_suffix]
2255
+ is [.cmj] if it has [ml] (in this case does not care about mli or not)
2256
+ is [.cmi] if it has [mli]
2257
+ *)
2258
+ let oc_cmi buf namespace source =
2259
+ Ext_buffer.add_char buf ' ';
2260
+ output_file buf source namespace;
2261
+ Ext_buffer.add_string buf Literals.suffix_cmi
2262
+
2263
+ (* For cases with self cycle
2264
+ e.g, in b.ml
2265
+ {[
2266
+ include B
2267
+ ]}
2268
+ When ns is not turned on, it makes sense that b may come from third party package.
2269
+ Hoever, this case is wont supported.
2270
+ It complicates when it has interface file or not.
2271
+ - if it has interface file, the current interface will have priority, failed to build?
2272
+ - if it does not have interface file, the build will not open this module at all(-bs-read-cmi)
2273
+
2274
+ When ns is turned on, `B` is interprted as `Ns-B` which is a cyclic dependency,
2275
+ it can be errored out earlier
2276
+
2277
+ #5368: It turns out there are many false positives on detecting self-cycles (see: `jscomp/build_tests/zerocycle`)
2278
+ To properly solve this, we would need to `jscomp/ml/depend.ml` because
2279
+ cmi and cmj is broken in the first place (same problem as in ocaml/ocaml#4618).
2280
+ So we will just ignore the self-cycles. Even if there is indeed a self-cycle, it should fail to compile anyway.
2281
+ *)
2282
+ let oc_deps (ast_file : string) (is_dev : bool) (db : Bsb_db_decode.t)
2283
+ (namespace : string option) (buf : Ext_buffer.t) (kind : [ `impl | `intf ])
2284
+ : unit =
2285
+ (* TODO: move namespace upper, it is better to resolve ealier *)
2286
+ let cur_module_name = Ext_filename.module_name ast_file in
2287
+ let at_most_once : unit lazy_t =
2288
+ lazy
2289
+ (output_file buf (Ext_filename.chop_extension_maybe ast_file) namespace;
2290
+ Ext_buffer.add_string buf
2291
+ (if kind = `impl then Literals.suffix_cmj else Literals.suffix_cmi);
2292
+ (* print the source *)
2293
+ Ext_buffer.add_string buf dep_lit)
2294
+ in
2295
+ (match namespace with
2296
+ | None -> ()
2297
+ | Some ns ->
2298
+ Lazy.force at_most_once;
2299
+ Ext_buffer.add_char buf ' ';
2300
+ Ext_buffer.add_string buf ns;
2301
+ Ext_buffer.add_string buf Literals.suffix_cmi (* always cmi *));
2302
+ (* TODO: moved into static files*)
2303
+ let s = extract_dep_raw_string ast_file in
2304
+ let offset = ref 1 in
2305
+ let size = String.length s in
2306
+ while !offset < size do
2307
+ let next_tab = String.index_from s !offset magic_sep_char in
2308
+ let dependent_module = String.sub s !offset (next_tab - !offset) in
2309
+ (if dependent_module = cur_module_name then
2310
+ (*prerr_endline ("FAILED: " ^ cur_module_name ^ " has a self cycle");
2311
+ exit 2*)
2312
+ (* #5368 ignore self dependencies *) ()
2313
+ else
2314
+ match Bsb_db_decode.find db dependent_module is_dev with
2315
+ | None -> ()
2316
+ | Some { dir_name; case } ->
2317
+ Lazy.force at_most_once;
2318
+ let source =
2319
+ Filename.concat dir_name
2320
+ (if case then dependent_module
2321
+ else Ext_string.uncapitalize_ascii dependent_module)
2322
+ in
2323
+ Ext_buffer.add_char buf ' ';
2324
+ if kind = `impl then (
2325
+ output_file buf source namespace;
2326
+ Ext_buffer.add_string buf Literals.suffix_cmj);
2327
+ (* #3260 cmj changes does not imply cmi change anymore *)
2328
+ oc_cmi buf namespace source);
2329
+ offset := next_tab + 1
2330
+ done;
2331
+ if Lazy.is_val at_most_once then Ext_buffer.add_char buf '\n'
2332
+
2333
+ let emit_d (is_dev : bool) (namespace : string option) (mlast : string)
2334
+ (mliast : string) =
2335
+ let data = Bsb_db_decode.read_build_cache ~dir:Filename.current_dir_name in
2336
+ let buf = Ext_buffer.create 2048 in
2337
+ let filename = Ext_filename.new_extension mlast Literals.suffix_d in
2338
+ oc_deps mlast is_dev data namespace buf `impl;
2339
+ if mliast <> "" then oc_deps mliast is_dev data namespace buf `intf;
2340
+ write_file filename buf
2341
+
2342
+ end
2343
+ module Bsb_helper_main : sig
2344
+ #1 "bsb_helper_main.mli"
2345
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2346
+ *
2347
+ * This program is free software: you can redistribute it and/or modify
2348
+ * it under the terms of the GNU Lesser General Public License as published by
2349
+ * the Free Software Foundation, either version 3 of the License, or
2350
+ * (at your option) any later version.
2351
+ *
2352
+ * In addition to the permissions granted to you by the LGPL, you may combine
2353
+ * or link a "work that uses the Library" with a publicly distributed version
2354
+ * of this file to produce a combined library or application, then distribute
2355
+ * that combined work under the terms of your choosing, with no requirement
2356
+ * to comply with the obligations normally placed on you by section 4 of the
2357
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2358
+ * should you choose to use a later version).
2359
+ *
2360
+ * This program is distributed in the hope that it will be useful,
2361
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2362
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2363
+ * GNU Lesser General Public License for more details.
2364
+ *
2365
+ * You should have received a copy of the GNU Lesser General Public License
2366
+ * along with this program; if not, write to the Free Software
2367
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2368
+
2369
+ (** Used to generate .d file, for example
2370
+ {[
2371
+ bsb_helper.exe -g 0 -MD src/hi/hello.ml
2372
+ ]}
2373
+ It will read the cache file and generate the corresponding
2374
+ [.d] file. This [.d] file will be used as attribute [depfile]
2375
+ whether we use namespace or not, the filename of [.mlast], [.d]
2376
+ should be kept the same, we only need change the name of [.cm*]
2377
+ and the contents of filename in [.d]
2378
+ *)
2379
+
2380
+ end = struct
2381
+ #1 "bsb_helper_main.ml"
2382
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2383
+ *
2384
+ * This program is free software: you can redistribute it and/or modify
2385
+ * it under the terms of the GNU Lesser General Public License as published by
2386
+ * the Free Software Foundation, either version 3 of the License, or
2387
+ * (at your option) any later version.
2388
+ *
2389
+ * In addition to the permissions granted to you by the LGPL, you may combine
2390
+ * or link a "work that uses the Library" with a publicly distributed version
2391
+ * of this file to produce a combined library or application, then distribute
2392
+ * that combined work under the terms of your choosing, with no requirement
2393
+ * to comply with the obligations normally placed on you by section 4 of the
2394
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
2395
+ * should you choose to use a later version).
2396
+ *
2397
+ * This program is distributed in the hope that it will be useful,
2398
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2399
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2400
+ * GNU Lesser General Public License for more details.
2401
+ *
2402
+ * You should have received a copy of the GNU Lesser General Public License
2403
+ * along with this program; if not, write to the Free Software
2404
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2405
+
2406
+ let () =
2407
+ let namespace = ref None in
2408
+ let dev_group = ref false in
2409
+ let argv = Sys.argv in
2410
+ let l = Array.length argv in
2411
+ let current = ref 1 in
2412
+ let rev_list = ref [] in
2413
+ while !current < l do
2414
+ let s = argv.(!current) in
2415
+ incr current;
2416
+ if s <> "" && s.[0] = '-' then (
2417
+ match s with
2418
+ | "-hash" -> incr current
2419
+ | "-bs-ns" ->
2420
+ let ns = argv.(!current) in
2421
+ namespace := Some ns;
2422
+ incr current
2423
+ | "-g" -> dev_group := true
2424
+ | s ->
2425
+ prerr_endline ("unknown options: " ^ s);
2426
+ prerr_endline "available options: -hash [hash]; -bs-ns [ns]; -g";
2427
+ exit 2)
2428
+ else rev_list := s :: !rev_list
2429
+ done;
2430
+ match !rev_list with
2431
+ | [ x ] -> Bsb_helper_depfile_gen.emit_d !dev_group !namespace x ""
2432
+ | [ y; x ] (* reverse order *) ->
2433
+ Bsb_helper_depfile_gen.emit_d !dev_group !namespace x y
2434
+ | _ -> ()
2435
+
2436
+ end