+535
| // Generated by Melange | ||
| import * as Caml_array from "melange.js/caml_array.js"; | ||
| import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| import * as Caml_obj from "melange.js/caml_obj.js"; | ||
| import * as Caml_option from "melange.js/caml_option.js"; | ||
| import * as Curry from "melange.js/curry.js"; | ||
| import * as Stdlib__Array from "./array.js"; | ||
| const init = Stdlib__Array.init; | ||
| function append(a1, a2) { | ||
| if (a1.length === 0) { | ||
| return a2; | ||
| } else if (a2.length === 0) { | ||
| return a1; | ||
| } else { | ||
| return Caml_external_polyfill.resolve("caml_array_append")(a1, a2); | ||
| } | ||
| } | ||
| function sub(a, pos, len) { | ||
| if (pos < 0 || len < 0 || pos > (a.length - len | 0)) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.sub" | ||
| }); | ||
| } | ||
| return Caml_array.sub(a, pos, len); | ||
| } | ||
| function iter(f, a) { | ||
| for (let i = 0, i_finish = a.length; i < i_finish; ++i) { | ||
| Curry._1(f, a[i]); | ||
| } | ||
| } | ||
| function iter2(f, a, b) { | ||
| if (a.length !== b.length) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.iter2: arrays must have the same length" | ||
| }); | ||
| } | ||
| for (let i = 0, i_finish = a.length; i < i_finish; ++i) { | ||
| Curry._2(f, a[i], b[i]); | ||
| } | ||
| } | ||
| function map(f, a) { | ||
| const l = a.length; | ||
| let tmp; | ||
| if (l === 0) { | ||
| tmp = []; | ||
| } else { | ||
| const r = Caml_array.make(l, Curry._1(f, a[0])); | ||
| for (let i = 1; i < l; ++i) { | ||
| r[i] = Curry._1(f, a[i]); | ||
| } | ||
| tmp = r; | ||
| } | ||
| return tmp; | ||
| } | ||
| function map2(f, a, b) { | ||
| const la = a.length; | ||
| const lb = b.length; | ||
| if (la !== lb) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.map2: arrays must have the same length" | ||
| }); | ||
| } | ||
| let tmp; | ||
| if (la === 0) { | ||
| tmp = []; | ||
| } else { | ||
| const r = Caml_array.make(la, Curry._2(f, a[0], b[0])); | ||
| for (let i = 1; i < la; ++i) { | ||
| r[i] = Curry._2(f, a[i], b[i]); | ||
| } | ||
| tmp = r; | ||
| } | ||
| return tmp; | ||
| } | ||
| function iteri(f, a) { | ||
| for (let i = 0, i_finish = a.length; i < i_finish; ++i) { | ||
| Curry._2(f, i, a[i]); | ||
| } | ||
| } | ||
| function mapi(f, a) { | ||
| const l = a.length; | ||
| let tmp; | ||
| if (l === 0) { | ||
| tmp = []; | ||
| } else { | ||
| const r = Caml_array.make(l, Curry._2(f, 0, a[0])); | ||
| for (let i = 1; i < l; ++i) { | ||
| r[i] = Curry._2(f, i, a[i]); | ||
| } | ||
| tmp = r; | ||
| } | ||
| return tmp; | ||
| } | ||
| function to_list(a) { | ||
| let _i = a.length - 1 | 0; | ||
| let _res = /* [] */ 0; | ||
| while (true) { | ||
| const res = _res; | ||
| const i = _i; | ||
| if (i < 0) { | ||
| return res; | ||
| } | ||
| _res = { | ||
| hd: a[i], | ||
| tl: res | ||
| }; | ||
| _i = i - 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| const of_list = Stdlib__Array.of_list; | ||
| const to_array = Stdlib__Array.copy; | ||
| const of_array = Stdlib__Array.copy; | ||
| function fold_left(f, x, a) { | ||
| let r = x; | ||
| for (let i = 0, i_finish = a.length; i < i_finish; ++i) { | ||
| r = Curry._2(f, r, a[i]); | ||
| } | ||
| return r; | ||
| } | ||
| function fold_left_map(f, acc, input_array) { | ||
| const len = input_array.length; | ||
| let match; | ||
| if (len === 0) { | ||
| match = [ | ||
| acc, | ||
| [] | ||
| ]; | ||
| } else { | ||
| const match$1 = Curry._2(f, acc, input_array[0]); | ||
| const output_array = Caml_array.make(len, match$1[1]); | ||
| let acc$1 = match$1[0]; | ||
| for (let i = 1; i < len; ++i) { | ||
| const match$2 = Curry._2(f, acc$1, input_array[i]); | ||
| acc$1 = match$2[0]; | ||
| output_array[i] = match$2[1]; | ||
| } | ||
| match = [ | ||
| acc$1, | ||
| output_array | ||
| ]; | ||
| } | ||
| return [ | ||
| match[0], | ||
| match[1] | ||
| ]; | ||
| } | ||
| function fold_right(f, a, x) { | ||
| let r = x; | ||
| for (let i = a.length - 1 | 0; i >= 0; --i) { | ||
| r = Curry._2(f, a[i], r); | ||
| } | ||
| return r; | ||
| } | ||
| function exists(p, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return false; | ||
| } | ||
| if (Curry._1(p, a[i])) { | ||
| return true; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function for_all(p, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return true; | ||
| } | ||
| if (!Curry._1(p, a[i])) { | ||
| return false; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function for_all2(p, l1, l2) { | ||
| const n1 = l1.length; | ||
| const n2 = l2.length; | ||
| if (n1 !== n2) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.for_all2" | ||
| }); | ||
| } | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n1) { | ||
| return true; | ||
| } | ||
| if (!Curry._2(p, l1[i], l2[i])) { | ||
| return false; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function exists2(p, l1, l2) { | ||
| const n1 = l1.length; | ||
| const n2 = l2.length; | ||
| if (n1 !== n2) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.exists2" | ||
| }); | ||
| } | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n1) { | ||
| return false; | ||
| } | ||
| if (Curry._2(p, l1[i], l2[i])) { | ||
| return true; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function equal(eq, a1, a2) { | ||
| if (a1.length === a2.length) { | ||
| return for_all2(eq, a1, a2); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| function compare(cmp, a1, a2) { | ||
| if (a1.length !== a2.length) { | ||
| return a1.length - a2.length | 0; | ||
| } | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === a1.length) { | ||
| return 0; | ||
| } | ||
| const c = Curry._2(cmp, a1[i], a2[i]); | ||
| if (c !== 0) { | ||
| return c; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function mem(x, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return false; | ||
| } | ||
| if (Caml_obj.caml_equal(a[i], x)) { | ||
| return true; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function memq(x, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return false; | ||
| } | ||
| if (x === a[i]) { | ||
| return true; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function find_opt(p, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return; | ||
| } | ||
| const x = a[i]; | ||
| if (Curry._1(p, x)) { | ||
| return Caml_option.some(x); | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function find_index(p, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return; | ||
| } | ||
| if (Curry._1(p, a[i])) { | ||
| return i; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function find_map(f, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return; | ||
| } | ||
| const r = Curry._1(f, a[i]); | ||
| if (r !== undefined) { | ||
| return r; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function find_mapi(f, a) { | ||
| const n = a.length; | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === n) { | ||
| return; | ||
| } | ||
| const r = Curry._2(f, i, a[i]); | ||
| if (r !== undefined) { | ||
| return r; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function split(x) { | ||
| if (equal(Caml_obj.caml_equal, x, [])) { | ||
| return [ | ||
| [], | ||
| [] | ||
| ]; | ||
| } | ||
| const match = x[0]; | ||
| const n = x.length; | ||
| const a = Caml_array.make(n, match[0]); | ||
| const b = Caml_array.make(n, match[1]); | ||
| for (let i = 1; i < n; ++i) { | ||
| const match$1 = x[i]; | ||
| a[i] = match$1[0]; | ||
| b[i] = match$1[1]; | ||
| } | ||
| return [ | ||
| a, | ||
| b | ||
| ]; | ||
| } | ||
| function combine(a, b) { | ||
| const na = a.length; | ||
| const nb = b.length; | ||
| if (na !== nb) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Iarray.combine" | ||
| }); | ||
| } | ||
| let tmp; | ||
| if (na === 0) { | ||
| tmp = []; | ||
| } else { | ||
| const x = Caml_array.make(na, [ | ||
| a[0], | ||
| b[0] | ||
| ]); | ||
| for (let i = 1; i < na; ++i) { | ||
| x[i] = [ | ||
| a[i], | ||
| b[i] | ||
| ]; | ||
| } | ||
| tmp = x; | ||
| } | ||
| return tmp; | ||
| } | ||
| function lift_sort(sorter, cmp, iarr) { | ||
| const arr = Stdlib__Array.copy(iarr); | ||
| Curry._2(sorter, cmp, arr); | ||
| return arr; | ||
| } | ||
| function sort(cmp, iarr) { | ||
| return lift_sort(Stdlib__Array.sort, cmp, iarr); | ||
| } | ||
| function stable_sort(cmp, iarr) { | ||
| return lift_sort(Stdlib__Array.stable_sort, cmp, iarr); | ||
| } | ||
| function fast_sort(cmp, iarr) { | ||
| return lift_sort(Stdlib__Array.fast_sort, cmp, iarr); | ||
| } | ||
| function to_seq(a) { | ||
| const aux = function (i, param) { | ||
| if (i >= a.length) { | ||
| return /* Nil */ 0; | ||
| } | ||
| const x = a[i]; | ||
| const partial_arg = i + 1 | 0; | ||
| return { | ||
| TAG: /* Cons */ 0, | ||
| _0: x, | ||
| _1: (function (param) { | ||
| return aux(partial_arg, param); | ||
| }) | ||
| }; | ||
| }; | ||
| return function (param) { | ||
| return aux(0, param); | ||
| }; | ||
| } | ||
| function to_seqi(a) { | ||
| const aux = function (i, param) { | ||
| if (i >= a.length) { | ||
| return /* Nil */ 0; | ||
| } | ||
| const x = a[i]; | ||
| const partial_arg = i + 1 | 0; | ||
| return { | ||
| TAG: /* Cons */ 0, | ||
| _0: [ | ||
| i, | ||
| x | ||
| ], | ||
| _1: (function (param) { | ||
| return aux(partial_arg, param); | ||
| }) | ||
| }; | ||
| }; | ||
| return function (param) { | ||
| return aux(0, param); | ||
| }; | ||
| } | ||
| const of_seq = Stdlib__Array.of_seq; | ||
| const concat = Caml_array.concat; | ||
| export { | ||
| init, | ||
| append, | ||
| concat, | ||
| sub, | ||
| to_list, | ||
| of_list, | ||
| to_array, | ||
| of_array, | ||
| equal, | ||
| compare, | ||
| iter, | ||
| iteri, | ||
| map, | ||
| mapi, | ||
| fold_left, | ||
| fold_left_map, | ||
| fold_right, | ||
| iter2, | ||
| map2, | ||
| for_all, | ||
| exists, | ||
| for_all2, | ||
| exists2, | ||
| mem, | ||
| memq, | ||
| find_opt, | ||
| find_index, | ||
| find_map, | ||
| find_mapi, | ||
| split, | ||
| combine, | ||
| sort, | ||
| stable_sort, | ||
| fast_sort, | ||
| to_seq, | ||
| to_seqi, | ||
| of_seq, | ||
| } | ||
| /* No side effect */ |
+87
| // Generated by Melange | ||
| import * as Curry from "melange.js/curry.js"; | ||
| function make(a, b) { | ||
| return [ | ||
| a, | ||
| b | ||
| ]; | ||
| } | ||
| function fst(param) { | ||
| return param[0]; | ||
| } | ||
| function snd(param) { | ||
| return param[1]; | ||
| } | ||
| function swap(param) { | ||
| return [ | ||
| param[1], | ||
| param[0] | ||
| ]; | ||
| } | ||
| function fold(f, param) { | ||
| return Curry._2(f, param[0], param[1]); | ||
| } | ||
| function map(f, g, param) { | ||
| return [ | ||
| Curry._1(f, param[0]), | ||
| Curry._1(g, param[1]) | ||
| ]; | ||
| } | ||
| function iter(f, g, param) { | ||
| Curry._1(f, param[0]); | ||
| return Curry._1(g, param[1]); | ||
| } | ||
| function map_fst(f, param) { | ||
| return [ | ||
| Curry._1(f, param[0]), | ||
| param[1] | ||
| ]; | ||
| } | ||
| function map_snd(g, param) { | ||
| return [ | ||
| param[0], | ||
| Curry._1(g, param[1]) | ||
| ]; | ||
| } | ||
| function equal(eqa, eqb, param, param$1) { | ||
| if (Curry._2(eqa, param[0], param$1[0])) { | ||
| return Curry._2(eqb, param[1], param$1[1]); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| function compare(cmpa, cmpb, param, param$1) { | ||
| const c = Curry._2(cmpa, param[0], param$1[0]); | ||
| if (c !== 0) { | ||
| return c; | ||
| } else { | ||
| return Curry._2(cmpb, param[1], param$1[1]); | ||
| } | ||
| } | ||
| export { | ||
| make, | ||
| fst, | ||
| snd, | ||
| swap, | ||
| fold, | ||
| map, | ||
| iter, | ||
| map_fst, | ||
| map_snd, | ||
| equal, | ||
| compare, | ||
| } | ||
| /* No side effect */ |
+571
| // Generated by Melange | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| import * as Caml_option from "melange.js/caml_option.js"; | ||
| import * as Curry from "melange.js/curry.js"; | ||
| import * as Stdlib__Dynarray from "./dynarray.js"; | ||
| function MakeMaxPoly(E) { | ||
| const left_child = function (i) { | ||
| return (i << 1) + 1 | 0; | ||
| }; | ||
| const right_child = function (i) { | ||
| return (i << 1) + 2 | 0; | ||
| }; | ||
| const parent_node = function (i) { | ||
| return (i - 1 | 0) / 2 | 0; | ||
| }; | ||
| const add = function (h, x) { | ||
| const i = h.length; | ||
| Stdlib__Dynarray.add_last(h, x); | ||
| if (i > 0) { | ||
| let _i = i; | ||
| while (true) { | ||
| const i$1 = _i; | ||
| if (i$1 === 0) { | ||
| return Stdlib__Dynarray.set(h, 0, x); | ||
| } | ||
| const p = parent_node(i$1); | ||
| const y = Stdlib__Dynarray.get(h, p); | ||
| if (Curry._2(E.compare, y, x) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i$1, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i$1, y); | ||
| _i = p; | ||
| continue; | ||
| }; | ||
| } | ||
| }; | ||
| const add_iter = function (h, iter, x) { | ||
| return Curry._2(iter, (function (param) { | ||
| return add(h, param); | ||
| }), x); | ||
| }; | ||
| const min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| return; | ||
| } else { | ||
| return Caml_option.some(Stdlib__Dynarray.get(h, 0)); | ||
| } | ||
| }; | ||
| const get_min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "empty priority queue" | ||
| }); | ||
| } | ||
| return Stdlib__Dynarray.get(h, 0); | ||
| }; | ||
| const lt = function (h, i, j) { | ||
| const y = Stdlib__Dynarray.get(h, j); | ||
| const x = Stdlib__Dynarray.get(h, i); | ||
| return Curry._2(E.compare, y, x) < 0; | ||
| }; | ||
| const sift_down = function (h, len, _i, x) { | ||
| while (true) { | ||
| const i = _i; | ||
| const left = left_child(i); | ||
| if (left >= len) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| const right = right_child(i); | ||
| const smallest = right >= len || lt(h, left, right) ? left : right; | ||
| const y = Stdlib__Dynarray.get(h, smallest); | ||
| if (Curry._2(E.compare, x, y) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i, y); | ||
| _i = smallest; | ||
| continue; | ||
| }; | ||
| }; | ||
| const pop_min = function (h) { | ||
| const n = h.length; | ||
| if (n === 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n === 1) { | ||
| return Caml_option.some(x); | ||
| } | ||
| const r = Stdlib__Dynarray.get(h, 0); | ||
| sift_down(h, n - 1 | 0, 0, x); | ||
| return Caml_option.some(r); | ||
| }; | ||
| const remove_min = function (h) { | ||
| const n = h.length; | ||
| if (n <= 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n > 1) { | ||
| return sift_down(h, n - 1 | 0, 0, x); | ||
| } | ||
| }; | ||
| const heapify = function (h) { | ||
| const n = h.length; | ||
| for (let i = (n / 2 | 0) - 1 | 0; i >= 0; --i) { | ||
| sift_down(h, n, i, Stdlib__Dynarray.get(h, i)); | ||
| } | ||
| return h; | ||
| }; | ||
| const of_array = function (a) { | ||
| return heapify(Stdlib__Dynarray.of_array(a)); | ||
| }; | ||
| const of_list = function (l) { | ||
| return heapify(Stdlib__Dynarray.of_list(l)); | ||
| }; | ||
| const of_iter = function (iter, x) { | ||
| const a = Stdlib__Dynarray.create(); | ||
| Curry._2(iter, (function (param) { | ||
| return Stdlib__Dynarray.add_last(a, param); | ||
| }), x); | ||
| return heapify(a); | ||
| }; | ||
| return { | ||
| create: Stdlib__Dynarray.create, | ||
| length: Stdlib__Dynarray.length, | ||
| is_empty: Stdlib__Dynarray.is_empty, | ||
| add: add, | ||
| add_iter: add_iter, | ||
| max_elt: min_elt, | ||
| get_max_elt: get_min_elt, | ||
| pop_max: pop_min, | ||
| remove_max: remove_min, | ||
| clear: Stdlib__Dynarray.clear, | ||
| copy: Stdlib__Dynarray.copy, | ||
| of_array: of_array, | ||
| of_list: of_list, | ||
| of_iter: of_iter, | ||
| iter_unordered: Stdlib__Dynarray.iter, | ||
| fold_unordered: Stdlib__Dynarray.fold_left | ||
| }; | ||
| } | ||
| function MakeMin(funarg) { | ||
| const compare = funarg.compare; | ||
| const left_child = function (i) { | ||
| return (i << 1) + 1 | 0; | ||
| }; | ||
| const right_child = function (i) { | ||
| return (i << 1) + 2 | 0; | ||
| }; | ||
| const parent_node = function (i) { | ||
| return (i - 1 | 0) / 2 | 0; | ||
| }; | ||
| const add = function (h, x) { | ||
| const i = h.length; | ||
| Stdlib__Dynarray.add_last(h, x); | ||
| if (i > 0) { | ||
| let _i = i; | ||
| while (true) { | ||
| const i$1 = _i; | ||
| if (i$1 === 0) { | ||
| return Stdlib__Dynarray.set(h, 0, x); | ||
| } | ||
| const p = parent_node(i$1); | ||
| const y = Stdlib__Dynarray.get(h, p); | ||
| if (Curry._2(compare, x, y) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i$1, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i$1, y); | ||
| _i = p; | ||
| continue; | ||
| }; | ||
| } | ||
| }; | ||
| const add_iter = function (h, iter, x) { | ||
| return Curry._2(iter, (function (param) { | ||
| return add(h, param); | ||
| }), x); | ||
| }; | ||
| const min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| return; | ||
| } else { | ||
| return Caml_option.some(Stdlib__Dynarray.get(h, 0)); | ||
| } | ||
| }; | ||
| const get_min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "empty priority queue" | ||
| }); | ||
| } | ||
| return Stdlib__Dynarray.get(h, 0); | ||
| }; | ||
| const lt = function (h, i, j) { | ||
| return Curry._2(compare, Stdlib__Dynarray.get(h, i), Stdlib__Dynarray.get(h, j)) < 0; | ||
| }; | ||
| const sift_down = function (h, len, _i, x) { | ||
| while (true) { | ||
| const i = _i; | ||
| const left = left_child(i); | ||
| if (left >= len) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| const right = right_child(i); | ||
| const smallest = right >= len || lt(h, left, right) ? left : right; | ||
| const y = Stdlib__Dynarray.get(h, smallest); | ||
| if (Curry._2(compare, y, x) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i, y); | ||
| _i = smallest; | ||
| continue; | ||
| }; | ||
| }; | ||
| const pop_min = function (h) { | ||
| const n = h.length; | ||
| if (n === 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n === 1) { | ||
| return Caml_option.some(x); | ||
| } | ||
| const r = Stdlib__Dynarray.get(h, 0); | ||
| sift_down(h, n - 1 | 0, 0, x); | ||
| return Caml_option.some(r); | ||
| }; | ||
| const remove_min = function (h) { | ||
| const n = h.length; | ||
| if (n <= 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n > 1) { | ||
| return sift_down(h, n - 1 | 0, 0, x); | ||
| } | ||
| }; | ||
| const heapify = function (h) { | ||
| const n = h.length; | ||
| for (let i = (n / 2 | 0) - 1 | 0; i >= 0; --i) { | ||
| sift_down(h, n, i, Stdlib__Dynarray.get(h, i)); | ||
| } | ||
| return h; | ||
| }; | ||
| const of_array = function (a) { | ||
| return heapify(Stdlib__Dynarray.of_array(a)); | ||
| }; | ||
| const of_list = function (l) { | ||
| return heapify(Stdlib__Dynarray.of_list(l)); | ||
| }; | ||
| const of_iter = function (iter, x) { | ||
| const a = Stdlib__Dynarray.create(); | ||
| Curry._2(iter, (function (param) { | ||
| return Stdlib__Dynarray.add_last(a, param); | ||
| }), x); | ||
| return heapify(a); | ||
| }; | ||
| return { | ||
| create: Stdlib__Dynarray.create, | ||
| length: Stdlib__Dynarray.length, | ||
| is_empty: Stdlib__Dynarray.is_empty, | ||
| add: add, | ||
| add_iter: add_iter, | ||
| min_elt: min_elt, | ||
| get_min_elt: get_min_elt, | ||
| pop_min: pop_min, | ||
| remove_min: remove_min, | ||
| clear: Stdlib__Dynarray.clear, | ||
| copy: Stdlib__Dynarray.copy, | ||
| of_array: of_array, | ||
| of_list: of_list, | ||
| of_iter: of_iter, | ||
| iter_unordered: Stdlib__Dynarray.iter, | ||
| fold_unordered: Stdlib__Dynarray.fold_left | ||
| }; | ||
| } | ||
| function MakeMax(funarg) { | ||
| const left_child = function (i) { | ||
| return (i << 1) + 1 | 0; | ||
| }; | ||
| const right_child = function (i) { | ||
| return (i << 1) + 2 | 0; | ||
| }; | ||
| const parent_node = function (i) { | ||
| return (i - 1 | 0) / 2 | 0; | ||
| }; | ||
| const add = function (h, x) { | ||
| const i = h.length; | ||
| Stdlib__Dynarray.add_last(h, x); | ||
| if (i > 0) { | ||
| let _i = i; | ||
| while (true) { | ||
| const i$1 = _i; | ||
| if (i$1 === 0) { | ||
| return Stdlib__Dynarray.set(h, 0, x); | ||
| } | ||
| const p = parent_node(i$1); | ||
| const y = Stdlib__Dynarray.get(h, p); | ||
| if (Curry._2(funarg.compare, y, x) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i$1, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i$1, y); | ||
| _i = p; | ||
| continue; | ||
| }; | ||
| } | ||
| }; | ||
| const add_iter = function (h, iter, x) { | ||
| return Curry._2(iter, (function (param) { | ||
| return add(h, param); | ||
| }), x); | ||
| }; | ||
| const min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| return; | ||
| } else { | ||
| return Caml_option.some(Stdlib__Dynarray.get(h, 0)); | ||
| } | ||
| }; | ||
| const get_min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "empty priority queue" | ||
| }); | ||
| } | ||
| return Stdlib__Dynarray.get(h, 0); | ||
| }; | ||
| const lt = function (h, i, j) { | ||
| const y = Stdlib__Dynarray.get(h, j); | ||
| const x = Stdlib__Dynarray.get(h, i); | ||
| return Curry._2(funarg.compare, y, x) < 0; | ||
| }; | ||
| const sift_down = function (h, len, _i, x) { | ||
| while (true) { | ||
| const i = _i; | ||
| const left = left_child(i); | ||
| if (left >= len) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| const right = right_child(i); | ||
| const smallest = right >= len || lt(h, left, right) ? left : right; | ||
| const y = Stdlib__Dynarray.get(h, smallest); | ||
| if (Curry._2(funarg.compare, x, y) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i, y); | ||
| _i = smallest; | ||
| continue; | ||
| }; | ||
| }; | ||
| const pop_min = function (h) { | ||
| const n = h.length; | ||
| if (n === 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n === 1) { | ||
| return Caml_option.some(x); | ||
| } | ||
| const r = Stdlib__Dynarray.get(h, 0); | ||
| sift_down(h, n - 1 | 0, 0, x); | ||
| return Caml_option.some(r); | ||
| }; | ||
| const remove_min = function (h) { | ||
| const n = h.length; | ||
| if (n <= 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n > 1) { | ||
| return sift_down(h, n - 1 | 0, 0, x); | ||
| } | ||
| }; | ||
| const heapify = function (h) { | ||
| const n = h.length; | ||
| for (let i = (n / 2 | 0) - 1 | 0; i >= 0; --i) { | ||
| sift_down(h, n, i, Stdlib__Dynarray.get(h, i)); | ||
| } | ||
| return h; | ||
| }; | ||
| const of_array = function (a) { | ||
| return heapify(Stdlib__Dynarray.of_array(a)); | ||
| }; | ||
| const of_list = function (l) { | ||
| return heapify(Stdlib__Dynarray.of_list(l)); | ||
| }; | ||
| const of_iter = function (iter, x) { | ||
| const a = Stdlib__Dynarray.create(); | ||
| Curry._2(iter, (function (param) { | ||
| return Stdlib__Dynarray.add_last(a, param); | ||
| }), x); | ||
| return heapify(a); | ||
| }; | ||
| return { | ||
| create: Stdlib__Dynarray.create, | ||
| length: Stdlib__Dynarray.length, | ||
| is_empty: Stdlib__Dynarray.is_empty, | ||
| add: add, | ||
| add_iter: add_iter, | ||
| max_elt: min_elt, | ||
| get_max_elt: get_min_elt, | ||
| pop_max: pop_min, | ||
| remove_max: remove_min, | ||
| clear: Stdlib__Dynarray.clear, | ||
| copy: Stdlib__Dynarray.copy, | ||
| of_array: of_array, | ||
| of_list: of_list, | ||
| of_iter: of_iter, | ||
| iter_unordered: Stdlib__Dynarray.iter, | ||
| fold_unordered: Stdlib__Dynarray.fold_left | ||
| }; | ||
| } | ||
| function MakeMinPoly(funarg) { | ||
| const left_child = function (i) { | ||
| return (i << 1) + 1 | 0; | ||
| }; | ||
| const right_child = function (i) { | ||
| return (i << 1) + 2 | 0; | ||
| }; | ||
| const parent_node = function (i) { | ||
| return (i - 1 | 0) / 2 | 0; | ||
| }; | ||
| const add = function (h, x) { | ||
| const i = h.length; | ||
| Stdlib__Dynarray.add_last(h, x); | ||
| if (i > 0) { | ||
| let _i = i; | ||
| while (true) { | ||
| const i$1 = _i; | ||
| if (i$1 === 0) { | ||
| return Stdlib__Dynarray.set(h, 0, x); | ||
| } | ||
| const p = parent_node(i$1); | ||
| const y = Stdlib__Dynarray.get(h, p); | ||
| if (Curry._2(funarg.compare, x, y) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i$1, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i$1, y); | ||
| _i = p; | ||
| continue; | ||
| }; | ||
| } | ||
| }; | ||
| const add_iter = function (h, iter, x) { | ||
| return Curry._2(iter, (function (param) { | ||
| return add(h, param); | ||
| }), x); | ||
| }; | ||
| const min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| return; | ||
| } else { | ||
| return Caml_option.some(Stdlib__Dynarray.get(h, 0)); | ||
| } | ||
| }; | ||
| const get_min_elt = function (h) { | ||
| if (h.length === 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "empty priority queue" | ||
| }); | ||
| } | ||
| return Stdlib__Dynarray.get(h, 0); | ||
| }; | ||
| const lt = function (h, i, j) { | ||
| return Curry._2(funarg.compare, Stdlib__Dynarray.get(h, i), Stdlib__Dynarray.get(h, j)) < 0; | ||
| }; | ||
| const sift_down = function (h, len, _i, x) { | ||
| while (true) { | ||
| const i = _i; | ||
| const left = left_child(i); | ||
| if (left >= len) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| const right = right_child(i); | ||
| const smallest = right >= len || lt(h, left, right) ? left : right; | ||
| const y = Stdlib__Dynarray.get(h, smallest); | ||
| if (Curry._2(funarg.compare, y, x) >= 0) { | ||
| return Stdlib__Dynarray.set(h, i, x); | ||
| } | ||
| Stdlib__Dynarray.set(h, i, y); | ||
| _i = smallest; | ||
| continue; | ||
| }; | ||
| }; | ||
| const pop_min = function (h) { | ||
| const n = h.length; | ||
| if (n === 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n === 1) { | ||
| return Caml_option.some(x); | ||
| } | ||
| const r = Stdlib__Dynarray.get(h, 0); | ||
| sift_down(h, n - 1 | 0, 0, x); | ||
| return Caml_option.some(r); | ||
| }; | ||
| const remove_min = function (h) { | ||
| const n = h.length; | ||
| if (n <= 0) { | ||
| return; | ||
| } | ||
| const x = Stdlib__Dynarray.pop_last(h); | ||
| if (n > 1) { | ||
| return sift_down(h, n - 1 | 0, 0, x); | ||
| } | ||
| }; | ||
| const heapify = function (h) { | ||
| const n = h.length; | ||
| for (let i = (n / 2 | 0) - 1 | 0; i >= 0; --i) { | ||
| sift_down(h, n, i, Stdlib__Dynarray.get(h, i)); | ||
| } | ||
| return h; | ||
| }; | ||
| const of_array = function (a) { | ||
| return heapify(Stdlib__Dynarray.of_array(a)); | ||
| }; | ||
| const of_list = function (l) { | ||
| return heapify(Stdlib__Dynarray.of_list(l)); | ||
| }; | ||
| const of_iter = function (iter, x) { | ||
| const a = Stdlib__Dynarray.create(); | ||
| Curry._2(iter, (function (param) { | ||
| return Stdlib__Dynarray.add_last(a, param); | ||
| }), x); | ||
| return heapify(a); | ||
| }; | ||
| return { | ||
| create: Stdlib__Dynarray.create, | ||
| length: Stdlib__Dynarray.length, | ||
| is_empty: Stdlib__Dynarray.is_empty, | ||
| add: add, | ||
| add_iter: add_iter, | ||
| min_elt: min_elt, | ||
| get_min_elt: get_min_elt, | ||
| pop_min: pop_min, | ||
| remove_min: remove_min, | ||
| clear: Stdlib__Dynarray.clear, | ||
| copy: Stdlib__Dynarray.copy, | ||
| of_array: of_array, | ||
| of_list: of_list, | ||
| of_iter: of_iter, | ||
| iter_unordered: Stdlib__Dynarray.iter, | ||
| fold_unordered: Stdlib__Dynarray.fold_left | ||
| }; | ||
| } | ||
| export { | ||
| MakeMin, | ||
| MakeMax, | ||
| MakeMinPoly, | ||
| MakeMaxPoly, | ||
| } | ||
| /* Stdlib__Dynarray Not a pure module */ |
+13
| // Generated by Melange | ||
| import * as Caml_obj from "melange.js/caml_obj.js"; | ||
| const min = Caml_obj.caml_min; | ||
| const max = Caml_obj.caml_max; | ||
| export { | ||
| min, | ||
| max, | ||
| } | ||
| /* No side effect */ |
+33
-73
@@ -7,3 +7,2 @@ // Generated by Melange | ||
| import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; | ||
| import * as Caml_format from "melange.js/caml_format.js"; | ||
| import * as Caml_io from "melange.js/caml_io.js"; | ||
@@ -229,41 +228,2 @@ import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| function bool_of_string_opt(x) { | ||
| try { | ||
| return Stdlib.bool_of_string(x); | ||
| } | ||
| catch (raw_exn){ | ||
| const exn = Caml_js_exceptions.internalToOCamlException(raw_exn); | ||
| if (exn.MEL_EXN_ID === Stdlib.Invalid_argument) { | ||
| return; | ||
| } | ||
| throw exn; | ||
| } | ||
| } | ||
| function int_of_string_opt(x) { | ||
| try { | ||
| return Caml_format.caml_int_of_string(x); | ||
| } | ||
| catch (raw_exn){ | ||
| const exn = Caml_js_exceptions.internalToOCamlException(raw_exn); | ||
| if (exn.MEL_EXN_ID === Stdlib.Failure) { | ||
| return; | ||
| } | ||
| throw exn; | ||
| } | ||
| } | ||
| function float_of_string_opt(x) { | ||
| try { | ||
| return Caml_format.caml_float_of_string(x); | ||
| } | ||
| catch (raw_exn){ | ||
| const exn = Caml_js_exceptions.internalToOCamlException(raw_exn); | ||
| if (exn.MEL_EXN_ID === Stdlib.Failure) { | ||
| return; | ||
| } | ||
| throw exn; | ||
| } | ||
| } | ||
| function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist, anonfun, errmsg) { | ||
@@ -490,7 +450,7 @@ const initpos = current.contents; | ||
| case /* Unit */ 0 : | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| return Curry._1(f._0, undefined); | ||
| case /* Bool */ 1 : | ||
| const arg = get_arg(undefined); | ||
| const s$1 = bool_of_string_opt(arg); | ||
| const arg = get_arg(); | ||
| const s$1 = Stdlib.bool_of_string_opt(arg); | ||
| if (s$1 !== undefined) { | ||
@@ -509,21 +469,21 @@ Curry._1(f._0, s$1); | ||
| } | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Set */ 2 : | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| f._0.contents = true; | ||
| return; | ||
| case /* Clear */ 3 : | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| f._0.contents = false; | ||
| return; | ||
| case /* String */ 4 : | ||
| const arg$1 = get_arg(undefined); | ||
| const arg$1 = get_arg(); | ||
| Curry._1(f._0, arg$1); | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Set_string */ 5 : | ||
| f._0.contents = get_arg(undefined); | ||
| return consume_arg(undefined); | ||
| f._0.contents = get_arg(); | ||
| return consume_arg(); | ||
| case /* Int */ 6 : | ||
| const arg$2 = get_arg(undefined); | ||
| const x = int_of_string_opt(arg$2); | ||
| const arg$2 = get_arg(); | ||
| const x = Stdlib.int_of_string_opt(arg$2); | ||
| if (x !== undefined) { | ||
@@ -542,6 +502,6 @@ Curry._1(f._0, x); | ||
| } | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Set_int */ 7 : | ||
| const arg$3 = get_arg(undefined); | ||
| const x$1 = int_of_string_opt(arg$3); | ||
| const arg$3 = get_arg(); | ||
| const x$1 = Stdlib.int_of_string_opt(arg$3); | ||
| if (x$1 !== undefined) { | ||
@@ -560,6 +520,6 @@ f._0.contents = x$1; | ||
| } | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Float */ 8 : | ||
| const arg$4 = get_arg(undefined); | ||
| const x$2 = float_of_string_opt(arg$4); | ||
| const arg$4 = get_arg(); | ||
| const x$2 = Stdlib.float_of_string_opt(arg$4); | ||
| if (x$2 !== undefined) { | ||
@@ -578,6 +538,6 @@ Curry._1(f._0, x$2); | ||
| } | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Set_float */ 9 : | ||
| const arg$5 = get_arg(undefined); | ||
| const x$3 = float_of_string_opt(arg$5); | ||
| const arg$5 = get_arg(); | ||
| const x$3 = Stdlib.float_of_string_opt(arg$5); | ||
| if (x$3 !== undefined) { | ||
@@ -596,12 +556,12 @@ f._0.contents = x$3; | ||
| } | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| case /* Tuple */ 10 : | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| return Stdlib__List.iter(treat_action, f._0); | ||
| case /* Symbol */ 11 : | ||
| const symb = f._0; | ||
| const arg$6 = get_arg(undefined); | ||
| const arg$6 = get_arg(); | ||
| if (Stdlib__List.mem(arg$6, symb)) { | ||
| Curry._1(f._1, arg$6); | ||
| return consume_arg(undefined); | ||
| return consume_arg(); | ||
| } | ||
@@ -619,10 +579,10 @@ throw new Caml_js_exceptions.MelangeError(Stop, { | ||
| const f$1 = f._0; | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| while (current.contents < (argv.contents.length - 1 | 0)) { | ||
| Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0)); | ||
| consume_arg(undefined); | ||
| consume_arg(); | ||
| }; | ||
| return; | ||
| case /* Rest_all */ 13 : | ||
| no_arg(undefined); | ||
| no_arg(); | ||
| let acc = /* [] */ 0; | ||
@@ -634,3 +594,3 @@ while (current.contents < (argv.contents.length - 1 | 0)) { | ||
| }; | ||
| consume_arg(undefined); | ||
| consume_arg(); | ||
| }; | ||
@@ -645,5 +605,5 @@ return Curry._1(f._0, Stdlib__List.rev(acc)); | ||
| } | ||
| const arg$7 = get_arg(undefined); | ||
| const arg$7 = get_arg(); | ||
| const newarg = Curry._1(f._0, arg$7); | ||
| consume_arg(undefined); | ||
| consume_arg(); | ||
| const before = Stdlib__Array.sub(argv.contents, 0, current.contents + 1 | 0); | ||
@@ -957,3 +917,3 @@ const after = Stdlib__Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); | ||
| if (c === sep) { | ||
| stash(undefined); | ||
| stash(); | ||
| } else { | ||
@@ -972,3 +932,3 @@ Stdlib__Buffer.add_char(buf, c); | ||
| if (buf.position > 0) { | ||
| stash(undefined); | ||
| stash(); | ||
| } | ||
@@ -975,0 +935,0 @@ Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); |
+36
-24
@@ -10,3 +10,2 @@ // Generated by Melange | ||
| import * as Stdlib__Seq from "./seq.js"; | ||
| import * as Stdlib__String from "./string.js"; | ||
@@ -250,2 +249,34 @@ const Floatarray = {}; | ||
| function equal(eq, a, b) { | ||
| if (a.length !== b.length) { | ||
| return false; | ||
| } | ||
| let i = 0; | ||
| const len = a.length; | ||
| while (i < len && Curry._2(eq, a[i], b[i])) { | ||
| i = i + 1 | 0; | ||
| }; | ||
| return i === len; | ||
| } | ||
| function compare(cmp, a, b) { | ||
| const len_a = a.length; | ||
| const len_b = b.length; | ||
| const diff = len_a - len_b | 0; | ||
| if (diff !== 0) { | ||
| if (diff < 0) { | ||
| return -1; | ||
| } else { | ||
| return 1; | ||
| } | ||
| } | ||
| let i = 0; | ||
| let c = 0; | ||
| while (i < len_a && c === 0) { | ||
| c = Curry._2(cmp, a[i], b[i]); | ||
| i = i + 1 | 0; | ||
| }; | ||
| return c; | ||
| } | ||
| function fold_left(f, x, a) { | ||
@@ -589,3 +620,3 @@ let r = x; | ||
| "array.cppo.ml", | ||
| 378, | ||
| 395, | ||
| 4 | ||
@@ -694,24 +725,3 @@ ] | ||
| function shuffle_contract_violation(i, j) { | ||
| const s = Stdlib__String.concat("", { | ||
| hd: "Array.shuffle: 'rand ", | ||
| tl: { | ||
| hd: String(i + 1 | 0), | ||
| tl: { | ||
| hd: "' returned ", | ||
| tl: { | ||
| hd: String(j), | ||
| tl: { | ||
| hd: ", out of expected range [0; ", | ||
| tl: { | ||
| hd: String(i), | ||
| tl: { | ||
| hd: "]", | ||
| tl: /* [] */ 0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| const s = "Array.shuffle: 'rand " + (String(i + 1 | 0) + ("' returned " + (String(j) + (", out of expected range [0; " + (String(i) + "]"))))); | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
@@ -821,2 +831,4 @@ MEL_EXN_ID: "Invalid_argument", | ||
| of_list, | ||
| equal, | ||
| compare, | ||
| iter, | ||
@@ -823,0 +835,0 @@ iteri, |
+6
-0
@@ -27,2 +27,6 @@ // Generated by Melange | ||
| const equal = Stdlib__Array.equal; | ||
| const compare = Stdlib__Array.compare; | ||
| const iter = Stdlib__Array.iter; | ||
@@ -102,2 +106,4 @@ | ||
| of_list, | ||
| equal, | ||
| compare, | ||
| iter, | ||
@@ -104,0 +110,0 @@ iteri, |
+26
-6
| // Generated by Melange | ||
| import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; | ||
| import * as CamlinternalAtomic from "./camlinternalAtomic.js"; | ||
| function set(t, v) { | ||
| Caml_external_polyfill.resolve("caml_atomic_exchange_field")(t[0], t[1], v); | ||
| } | ||
| function incr(t) { | ||
| Caml_external_polyfill.resolve("caml_atomic_fetch_add_field")(t[0], t[1], 1); | ||
| } | ||
| function decr(t) { | ||
| Caml_external_polyfill.resolve("caml_atomic_fetch_add_field")(t[0], t[1], -1); | ||
| } | ||
| const Loc = { | ||
| set: set, | ||
| incr: incr, | ||
| decr: decr | ||
| }; | ||
| const make = CamlinternalAtomic.make; | ||
@@ -9,3 +28,3 @@ | ||
| const set = CamlinternalAtomic.set; | ||
| const set$1 = CamlinternalAtomic.set; | ||
@@ -18,5 +37,5 @@ const exchange = CamlinternalAtomic.exchange; | ||
| const incr = CamlinternalAtomic.incr; | ||
| const incr$1 = CamlinternalAtomic.incr; | ||
| const decr = CamlinternalAtomic.decr; | ||
| const decr$1 = CamlinternalAtomic.decr; | ||
@@ -26,9 +45,10 @@ export { | ||
| get, | ||
| set, | ||
| set$1 as set, | ||
| exchange, | ||
| compare_and_set, | ||
| fetch_and_add, | ||
| incr, | ||
| decr, | ||
| incr$1 as incr, | ||
| decr$1 as decr, | ||
| Loc, | ||
| } | ||
| /* No side effect */ |
+15
-0
@@ -48,4 +48,19 @@ // Generated by Melange | ||
| function logand(prim0, prim1) { | ||
| return prim0 & prim1; | ||
| } | ||
| function logor(prim0, prim1) { | ||
| return prim0 | prim1; | ||
| } | ||
| function logxor(prim0, prim1) { | ||
| return prim0 ^ prim1; | ||
| } | ||
| export { | ||
| not, | ||
| logand, | ||
| logor, | ||
| logxor, | ||
| equal, | ||
@@ -52,0 +67,0 @@ compare, |
+1
-1
@@ -732,3 +732,3 @@ // Generated by Melange | ||
| if (n.contents === buf.contents.length) { | ||
| resize(undefined); | ||
| resize(); | ||
| } | ||
@@ -735,0 +735,0 @@ Caml_bytes.set(buf.contents, n.contents, c); |
| // Generated by Melange | ||
| import * as Curry from "melange.js/curry.js"; | ||
@@ -342,2 +343,165 @@ function erase_rel(rest) { | ||
| function string_concat_map(f, rest) { | ||
| if (/* tag */ typeof rest === "number" || typeof rest === "string") { | ||
| return /* End_of_format */ 0; | ||
| } | ||
| switch (rest.TAG) { | ||
| case /* Char */ 0 : | ||
| return { | ||
| TAG: /* Char */ 0, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* Caml_char */ 1 : | ||
| return { | ||
| TAG: /* Caml_char */ 1, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* String */ 2 : | ||
| return { | ||
| TAG: /* String */ 2, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Caml_string */ 3 : | ||
| return { | ||
| TAG: /* Caml_string */ 3, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Int */ 4 : | ||
| return { | ||
| TAG: /* Int */ 4, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: rest._2, | ||
| _3: string_concat_map(f, rest._3) | ||
| }; | ||
| case /* Int32 */ 5 : | ||
| return { | ||
| TAG: /* Int32 */ 5, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: rest._2, | ||
| _3: string_concat_map(f, rest._3) | ||
| }; | ||
| case /* Nativeint */ 6 : | ||
| return { | ||
| TAG: /* Nativeint */ 6, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: rest._2, | ||
| _3: string_concat_map(f, rest._3) | ||
| }; | ||
| case /* Int64 */ 7 : | ||
| return { | ||
| TAG: /* Int64 */ 7, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: rest._2, | ||
| _3: string_concat_map(f, rest._3) | ||
| }; | ||
| case /* Float */ 8 : | ||
| return { | ||
| TAG: /* Float */ 8, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: rest._2, | ||
| _3: string_concat_map(f, rest._3) | ||
| }; | ||
| case /* Bool */ 9 : | ||
| return { | ||
| TAG: /* Bool */ 9, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Flush */ 10 : | ||
| return { | ||
| TAG: /* Flush */ 10, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* String_literal */ 11 : | ||
| return Curry._2(f.f, { | ||
| NAME: "String", | ||
| VAL: rest._0 | ||
| }, string_concat_map(f, rest._1)); | ||
| case /* Char_literal */ 12 : | ||
| return Curry._2(f.f, { | ||
| NAME: "Char", | ||
| VAL: rest._0 | ||
| }, string_concat_map(f, rest._1)); | ||
| case /* Format_arg */ 13 : | ||
| return { | ||
| TAG: /* Format_arg */ 13, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: string_concat_map(f, rest._2) | ||
| }; | ||
| case /* Format_subst */ 14 : | ||
| return { | ||
| TAG: /* Format_subst */ 14, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: string_concat_map(f, rest._2) | ||
| }; | ||
| case /* Alpha */ 15 : | ||
| return { | ||
| TAG: /* Alpha */ 15, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* Theta */ 16 : | ||
| return { | ||
| TAG: /* Theta */ 16, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* Formatting_lit */ 17 : | ||
| return { | ||
| TAG: /* Formatting_lit */ 17, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Formatting_gen */ 18 : | ||
| return { | ||
| TAG: /* Formatting_gen */ 18, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Reader */ 19 : | ||
| return { | ||
| TAG: /* Reader */ 19, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* Scan_char_set */ 20 : | ||
| return { | ||
| TAG: /* Scan_char_set */ 20, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: string_concat_map(f, rest._2) | ||
| }; | ||
| case /* Scan_get_counter */ 21 : | ||
| return { | ||
| TAG: /* Scan_get_counter */ 21, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Scan_next_char */ 22 : | ||
| return { | ||
| TAG: /* Scan_next_char */ 22, | ||
| _0: string_concat_map(f, rest._0) | ||
| }; | ||
| case /* Ignored_param */ 23 : | ||
| return { | ||
| TAG: /* Ignored_param */ 23, | ||
| _0: rest._0, | ||
| _1: string_concat_map(f, rest._1) | ||
| }; | ||
| case /* Custom */ 24 : | ||
| return { | ||
| TAG: /* Custom */ 24, | ||
| _0: rest._0, | ||
| _1: rest._1, | ||
| _2: string_concat_map(f, rest._2) | ||
| }; | ||
| } | ||
| } | ||
| export { | ||
@@ -347,3 +511,4 @@ concat_fmtty, | ||
| concat_fmt, | ||
| string_concat_map, | ||
| } | ||
| /* No side effect */ |
+17
-0
@@ -5,2 +5,3 @@ // Generated by Melange | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| import * as Stdlib__Obj from "./obj.js"; | ||
@@ -63,2 +64,17 @@ const Undefined = /* @__PURE__ */ Caml_exceptions.create("CamlinternalLazy.Undefined"); | ||
| function indirect(lzv) { | ||
| const lzv$1 = lzv; | ||
| const t = lzv$1.TAG; | ||
| if (t === Stdlib__Obj.lazy_tag || t === Stdlib__Obj.forcing_tag) { | ||
| return { | ||
| LAZY_DONE: false, | ||
| VAL: (function () { | ||
| return force_lazy_block(lzv$1); | ||
| }) | ||
| }; | ||
| } else { | ||
| return lzv$1; | ||
| } | ||
| } | ||
| export { | ||
@@ -71,3 +87,4 @@ Undefined, | ||
| is_val, | ||
| indirect, | ||
| } | ||
| /* No side effect */ |
+67
-72
@@ -12,2 +12,3 @@ // Generated by Melange | ||
| import * as Stdlib__Array from "./array.js"; | ||
| import * as Stdlib__Atomic from "./atomic.js"; | ||
| import * as Stdlib__List from "./list.js"; | ||
@@ -518,5 +519,3 @@ | ||
| const table_count = { | ||
| contents: 0 | ||
| }; | ||
| const table_count = Stdlib__Atomic.make(0); | ||
@@ -532,3 +531,3 @@ function fit_size(n) { | ||
| function new_table(pub_labels) { | ||
| table_count.contents = table_count.contents + 1 | 0; | ||
| Stdlib__Atomic.incr(table_count); | ||
| const len = pub_labels.length; | ||
@@ -563,9 +562,5 @@ const methods = Caml_array.make((len << 1) + 2 | 0, /* DummyA */ 0); | ||
| const method_count = { | ||
| contents: 0 | ||
| }; | ||
| const method_count = Stdlib__Atomic.make(0); | ||
| const inst_var_count = { | ||
| contents: 0 | ||
| }; | ||
| const inst_var_count = Stdlib__Atomic.make(0); | ||
@@ -601,3 +596,3 @@ function new_method(table) { | ||
| function set_method(table, label, element) { | ||
| method_count.contents = method_count.contents + 1 | 0; | ||
| Stdlib__Atomic.incr(method_count); | ||
| if (Curry._2(find$2, label, table.methods_by_label)) { | ||
@@ -821,3 +816,3 @@ resize(table, label + 1 | 0); | ||
| function init_class(table) { | ||
| inst_var_count.contents = (inst_var_count.contents + table.size | 0) - 1 | 0; | ||
| Stdlib__Atomic.fetch_and_add(inst_var_count, table.size - 1 | 0); | ||
| table.initializers = Stdlib__List.rev(table.initializers); | ||
@@ -1073,3 +1068,3 @@ resize(table, 3 + ((Caml_array.get(table.methods, 1) << 4) / 32 | 0) | 0); | ||
| }; | ||
| const clo = next(undefined); | ||
| const clo = next(); | ||
| if (!/* tag */ (typeof clo === "number" || typeof clo === "string")) { | ||
@@ -1080,3 +1075,3 @@ return clo; | ||
| case /* GetConst */ 0 : | ||
| const partial_arg = next(undefined); | ||
| const partial_arg = next(); | ||
| return function (param) { | ||
@@ -1086,3 +1081,3 @@ return partial_arg; | ||
| case /* GetVar */ 1 : | ||
| const partial_arg$1 = next(undefined); | ||
| const partial_arg$1 = next(); | ||
| return function (param) { | ||
@@ -1092,4 +1087,4 @@ return param[partial_arg$1]; | ||
| case /* GetEnv */ 2 : | ||
| const e = next(undefined); | ||
| const n = next(undefined); | ||
| const e = next(); | ||
| const n = next(); | ||
| return function (param) { | ||
@@ -1099,3 +1094,3 @@ return param[e][n]; | ||
| case /* GetMeth */ 3 : | ||
| const partial_arg$2 = next(undefined); | ||
| const partial_arg$2 = next(); | ||
| return function (param) { | ||
@@ -1105,3 +1100,3 @@ return Curry._1(param[0][partial_arg$2], param); | ||
| case /* SetVar */ 4 : | ||
| const partial_arg$3 = next(undefined); | ||
| const partial_arg$3 = next(); | ||
| return function (param, param$1) { | ||
@@ -1111,4 +1106,4 @@ param[partial_arg$3] = param$1; | ||
| case /* AppConst */ 5 : | ||
| const f = next(undefined); | ||
| const x = next(undefined); | ||
| const f = next(); | ||
| const x = next(); | ||
| return function (param) { | ||
@@ -1118,4 +1113,4 @@ return Curry._1(f, x); | ||
| case /* AppVar */ 6 : | ||
| const f$1 = next(undefined); | ||
| const n$1 = next(undefined); | ||
| const f$1 = next(); | ||
| const n$1 = next(); | ||
| return function (param) { | ||
@@ -1125,5 +1120,5 @@ return Curry._1(f$1, param[n$1]); | ||
| case /* AppEnv */ 7 : | ||
| const f$2 = next(undefined); | ||
| const e$1 = next(undefined); | ||
| const n$2 = next(undefined); | ||
| const f$2 = next(); | ||
| const e$1 = next(); | ||
| const n$2 = next(); | ||
| return function (param) { | ||
@@ -1133,4 +1128,4 @@ return Curry._1(f$2, param[e$1][n$2]); | ||
| case /* AppMeth */ 8 : | ||
| const f$3 = next(undefined); | ||
| const n$3 = next(undefined); | ||
| const f$3 = next(); | ||
| const n$3 = next(); | ||
| return function (param) { | ||
@@ -1140,5 +1135,5 @@ return Curry._1(f$3, Curry._1(param[0][n$3], param)); | ||
| case /* AppConstConst */ 9 : | ||
| const f$4 = next(undefined); | ||
| const x$1 = next(undefined); | ||
| const y = next(undefined); | ||
| const f$4 = next(); | ||
| const x$1 = next(); | ||
| const y = next(); | ||
| return function (param) { | ||
@@ -1148,5 +1143,5 @@ return Curry._2(f$4, x$1, y); | ||
| case /* AppConstVar */ 10 : | ||
| const f$5 = next(undefined); | ||
| const x$2 = next(undefined); | ||
| const n$4 = next(undefined); | ||
| const f$5 = next(); | ||
| const x$2 = next(); | ||
| const n$4 = next(); | ||
| return function (param) { | ||
@@ -1156,6 +1151,6 @@ return Curry._2(f$5, x$2, param[n$4]); | ||
| case /* AppConstEnv */ 11 : | ||
| const f$6 = next(undefined); | ||
| const x$3 = next(undefined); | ||
| const e$2 = next(undefined); | ||
| const n$5 = next(undefined); | ||
| const f$6 = next(); | ||
| const x$3 = next(); | ||
| const e$2 = next(); | ||
| const n$5 = next(); | ||
| return function (param) { | ||
@@ -1165,5 +1160,5 @@ return Curry._2(f$6, x$3, param[e$2][n$5]); | ||
| case /* AppConstMeth */ 12 : | ||
| const f$7 = next(undefined); | ||
| const x$4 = next(undefined); | ||
| const n$6 = next(undefined); | ||
| const f$7 = next(); | ||
| const x$4 = next(); | ||
| const n$6 = next(); | ||
| return function (param) { | ||
@@ -1173,5 +1168,5 @@ return Curry._2(f$7, x$4, Curry._1(param[0][n$6], param)); | ||
| case /* AppVarConst */ 13 : | ||
| const f$8 = next(undefined); | ||
| const n$7 = next(undefined); | ||
| const x$5 = next(undefined); | ||
| const f$8 = next(); | ||
| const n$7 = next(); | ||
| const x$5 = next(); | ||
| return function (param) { | ||
@@ -1181,6 +1176,6 @@ return Curry._2(f$8, param[n$7], x$5); | ||
| case /* AppEnvConst */ 14 : | ||
| const f$9 = next(undefined); | ||
| const e$3 = next(undefined); | ||
| const n$8 = next(undefined); | ||
| const x$6 = next(undefined); | ||
| const f$9 = next(); | ||
| const e$3 = next(); | ||
| const n$8 = next(); | ||
| const x$6 = next(); | ||
| return function (param) { | ||
@@ -1190,5 +1185,5 @@ return Curry._2(f$9, param[e$3][n$8], x$6); | ||
| case /* AppMethConst */ 15 : | ||
| const f$10 = next(undefined); | ||
| const n$9 = next(undefined); | ||
| const x$7 = next(undefined); | ||
| const f$10 = next(); | ||
| const n$9 = next(); | ||
| const x$7 = next(); | ||
| return function (param) { | ||
@@ -1198,4 +1193,4 @@ return Curry._2(f$10, Curry._1(param[0][n$9], param), x$7); | ||
| case /* MethAppConst */ 16 : | ||
| const n$10 = next(undefined); | ||
| const x$8 = next(undefined); | ||
| const n$10 = next(); | ||
| const x$8 = next(); | ||
| return function (param) { | ||
@@ -1205,4 +1200,4 @@ return Curry._2(param[0][n$10], param, x$8); | ||
| case /* MethAppVar */ 17 : | ||
| const n$11 = next(undefined); | ||
| const m = next(undefined); | ||
| const n$11 = next(); | ||
| const m = next(); | ||
| return function (param) { | ||
@@ -1212,5 +1207,5 @@ return Curry._2(param[0][n$11], param, param[m]); | ||
| case /* MethAppEnv */ 18 : | ||
| const n$12 = next(undefined); | ||
| const e$4 = next(undefined); | ||
| const m$1 = next(undefined); | ||
| const n$12 = next(); | ||
| const e$4 = next(); | ||
| const m$1 = next(); | ||
| return function (param) { | ||
@@ -1220,4 +1215,4 @@ return Curry._2(param[0][n$12], param, param[e$4][m$1]); | ||
| case /* MethAppMeth */ 19 : | ||
| const n$13 = next(undefined); | ||
| const m$2 = next(undefined); | ||
| const n$13 = next(); | ||
| const m$2 = next(); | ||
| return function (param) { | ||
@@ -1227,4 +1222,4 @@ return Curry._2(param[0][n$13], param, Curry._1(param[0][m$2], param)); | ||
| case /* SendConst */ 20 : | ||
| const m$3 = next(undefined); | ||
| const x$9 = next(undefined); | ||
| const m$3 = next(); | ||
| const x$9 = next(); | ||
| const partial_arg$4 = new_cache(table); | ||
@@ -1235,4 +1230,4 @@ return function (param) { | ||
| case /* SendVar */ 21 : | ||
| const m$4 = next(undefined); | ||
| const n$14 = next(undefined); | ||
| const m$4 = next(); | ||
| const n$14 = next(); | ||
| const partial_arg$5 = new_cache(table); | ||
@@ -1244,5 +1239,5 @@ return function (param) { | ||
| case /* SendEnv */ 22 : | ||
| const m$5 = next(undefined); | ||
| const e$5 = next(undefined); | ||
| const n$15 = next(undefined); | ||
| const m$5 = next(); | ||
| const e$5 = next(); | ||
| const n$15 = next(); | ||
| const partial_arg$6 = new_cache(table); | ||
@@ -1254,4 +1249,4 @@ return function (param) { | ||
| case /* SendMeth */ 23 : | ||
| const m$6 = next(undefined); | ||
| const n$16 = next(undefined); | ||
| const m$6 = next(); | ||
| const n$16 = next(); | ||
| const partial_arg$7 = new_cache(table); | ||
@@ -1280,5 +1275,5 @@ return function (param) { | ||
| return { | ||
| classes: table_count.contents, | ||
| methods: method_count.contents, | ||
| inst_vars: inst_var_count.contents | ||
| classes: Stdlib__Atomic.get(table_count), | ||
| methods: Stdlib__Atomic.get(method_count), | ||
| inst_vars: Stdlib__Atomic.get(inst_var_count) | ||
| }; | ||
@@ -1285,0 +1280,0 @@ } |
+154
-2
@@ -6,2 +6,3 @@ // Generated by Melange | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| import * as Stdlib from "./stdlib.js"; | ||
@@ -108,9 +109,160 @@ function chr(n) { | ||
| function is_valid(param) { | ||
| return param < 128; | ||
| } | ||
| function is_upper(param) { | ||
| return !(param > 90 || param < 65); | ||
| } | ||
| function is_lower(param) { | ||
| return !(param > 122 || param < 97); | ||
| } | ||
| function is_letter(param) { | ||
| if (param >= 91) { | ||
| return !(param > 122 || param < 97); | ||
| } else { | ||
| return param >= 65; | ||
| } | ||
| } | ||
| function is_alphanum(param) { | ||
| if (param > 90 || param < 48) { | ||
| return !(param > 122 || param < 97); | ||
| } else { | ||
| return param > 64 || param < 58; | ||
| } | ||
| } | ||
| function is_white(param) { | ||
| if (param >= 14) { | ||
| return param === 32; | ||
| } else { | ||
| return param >= 9; | ||
| } | ||
| } | ||
| function is_blank(param) { | ||
| if (param !== 9) { | ||
| return param === 32; | ||
| } else { | ||
| return true; | ||
| } | ||
| } | ||
| function is_graphic(param) { | ||
| return !(param > 126 || param < 33); | ||
| } | ||
| function is_print(param) { | ||
| return !(param > 126 || param < 32); | ||
| } | ||
| function is_control(param) { | ||
| if (param !== 127) { | ||
| return param < 32; | ||
| } else { | ||
| return true; | ||
| } | ||
| } | ||
| function is_digit(param) { | ||
| return !(param > 57 || param < 48); | ||
| } | ||
| function digit_to_int(c) { | ||
| if (!(c > 57 || c < 48)) { | ||
| return c - 48 | 0; | ||
| } | ||
| const s = escaped(c) + ": not a decimal digit"; | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: s | ||
| }); | ||
| } | ||
| function digit_of_int(n) { | ||
| return 48 + Stdlib.abs(n % 10) | 0; | ||
| } | ||
| function is_hex_digit(param) { | ||
| if (param > 70 || param < 48) { | ||
| return !(param > 102 || param < 97); | ||
| } else { | ||
| return param > 64 || param < 58; | ||
| } | ||
| } | ||
| function hex_digit_to_int(c) { | ||
| if (c >= 65) { | ||
| if (c >= 97) { | ||
| if (c < 103) { | ||
| return (10 + c | 0) - 97 | 0; | ||
| } | ||
| } else if (c < 71) { | ||
| return (10 + c | 0) - 65 | 0; | ||
| } | ||
| } else if (!(c > 57 || c < 48)) { | ||
| return c - 48 | 0; | ||
| } | ||
| const s = escaped(c) + ": not a hexadecimal digit"; | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: s | ||
| }); | ||
| } | ||
| function lower_hex_digit_of_int(n) { | ||
| const d = Stdlib.abs(n % 16); | ||
| if (d < 10) { | ||
| return 48 + d | 0; | ||
| } else { | ||
| return 87 + d | 0; | ||
| } | ||
| } | ||
| function upper_hex_digit_of_int(n) { | ||
| const d = Stdlib.abs(n % 16); | ||
| if (d < 10) { | ||
| return 48 + d | 0; | ||
| } else { | ||
| return 55 + d | 0; | ||
| } | ||
| } | ||
| const Ascii = { | ||
| min: /* '\000' */0, | ||
| max: /* '\127' */127, | ||
| is_valid: is_valid, | ||
| is_upper: is_upper, | ||
| is_lower: is_lower, | ||
| is_letter: is_letter, | ||
| is_alphanum: is_alphanum, | ||
| is_white: is_white, | ||
| is_blank: is_blank, | ||
| is_graphic: is_graphic, | ||
| is_print: is_print, | ||
| is_control: is_control, | ||
| is_digit: is_digit, | ||
| digit_to_int: digit_to_int, | ||
| digit_of_int: digit_of_int, | ||
| is_hex_digit: is_hex_digit, | ||
| hex_digit_to_int: hex_digit_to_int, | ||
| lower_hex_digit_of_int: lower_hex_digit_of_int, | ||
| upper_hex_digit_of_int: upper_hex_digit_of_int, | ||
| uppercase: uppercase_ascii, | ||
| lowercase: lowercase_ascii | ||
| }; | ||
| export { | ||
| chr, | ||
| escaped, | ||
| compare, | ||
| equal, | ||
| Ascii, | ||
| lowercase_ascii, | ||
| uppercase_ascii, | ||
| compare, | ||
| equal, | ||
| seeded_hash, | ||
@@ -117,0 +269,0 @@ hash, |
+2
-2
@@ -163,7 +163,7 @@ // Generated by Melange | ||
| function spawn(f) { | ||
| maybe_first_spawn(undefined); | ||
| maybe_first_spawn(); | ||
| const status = { | ||
| contents: /* Running */ 0 | ||
| }; | ||
| const split_keys = prepare_split_keys_before_spawn(undefined); | ||
| const split_keys = prepare_split_keys_before_spawn(); | ||
| const handle = new Promise((function (resolve, reject) { | ||
@@ -170,0 +170,0 @@ let param = [ |
+240
-64
@@ -5,2 +5,3 @@ // Generated by Melange | ||
| import * as Caml_array from "melange.js/caml_array.js"; | ||
| import * as Caml_exceptions from "melange.js/caml_exceptions.js"; | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
@@ -61,3 +62,3 @@ import * as Caml_obj from "melange.js/caml_obj.js"; | ||
| function copy(a, dummy) { | ||
| function copy_from_array(a, dummy) { | ||
| if (a.TAG !== Stdlib__Obj.double_array_tag) { | ||
@@ -74,10 +75,36 @@ return Stdlib__Array.copy(a); | ||
| function unsafe_nocopy(a, dummy) { | ||
| function unsafe_nocopy_from_array(a, dummy) { | ||
| if (a.TAG !== Stdlib__Obj.double_array_tag) { | ||
| return a; | ||
| } else { | ||
| return copy(a, dummy); | ||
| return copy_from_array(a, dummy); | ||
| } | ||
| } | ||
| const Dummy_found = /* @__PURE__ */ Caml_exceptions.create("Stdlib.Dynarray.Dummy.Array.Dummy_found"); | ||
| function unsafe_nocopy_to_array(a, dummy) { | ||
| let arr; | ||
| if (a.length === 0 || Caml_array.get(a, 0).TAG !== Stdlib__Obj.double_tag) { | ||
| arr = a; | ||
| } else { | ||
| const n = a.length; | ||
| const a$p = Caml_array.make(n, Caml_array.get(a, 0)); | ||
| for (let i = 1; i < n; ++i) { | ||
| a$p[i] = a[i]; | ||
| } | ||
| arr = a$p; | ||
| } | ||
| Stdlib__Array.iteri((function (i, v) { | ||
| if (v !== dummy) { | ||
| return; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError(Dummy_found, { | ||
| MEL_EXN_ID: Dummy_found, | ||
| _1: i | ||
| }); | ||
| }), arr); | ||
| return arr; | ||
| } | ||
| function init(n, f, dummy) { | ||
@@ -108,4 +135,4 @@ const arr = Caml_array.make(n, dummy); | ||
| _1: [ | ||
| "jscomp/stdlib/dynarray.ml", | ||
| 289, | ||
| "dynarray.cppo.ml", | ||
| 317, | ||
| 13 | ||
@@ -119,4 +146,4 @@ ] | ||
| _1: [ | ||
| "jscomp/stdlib/dynarray.ml", | ||
| 299, | ||
| "dynarray.cppo.ml", | ||
| 327, | ||
| 8 | ||
@@ -144,4 +171,6 @@ ] | ||
| init: init, | ||
| copy: copy, | ||
| unsafe_nocopy: unsafe_nocopy, | ||
| copy_from_array: copy_from_array, | ||
| unsafe_nocopy_from_array: unsafe_nocopy_from_array, | ||
| Dummy_found: Dummy_found, | ||
| unsafe_nocopy_to_array: unsafe_nocopy_to_array, | ||
| blit_array: blit_array, | ||
@@ -153,3 +182,3 @@ blit: blit, | ||
| const global_dummy = fresh(undefined); | ||
| const global_dummy = fresh(); | ||
@@ -392,2 +421,50 @@ function index_out_of_bounds(f, i, length) { | ||
| function length_change_during_iteration(f, expected, observed) { | ||
| return Curry._3(Stdlib__Printf.ksprintf(Stdlib.invalid_arg, { | ||
| TAG: /* Format */ 0, | ||
| _0: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: "Dynarray.", | ||
| _1: { | ||
| TAG: /* String */ 2, | ||
| _0: /* No_padding */ 0, | ||
| _1: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: ": a length change from ", | ||
| _1: { | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: " to ", | ||
| _1: { | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: " occurred during iteration", | ||
| _1: /* End_of_format */ 0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| _1: "Dynarray.%s: a length change from %d to %d occurred during iteration" | ||
| }), f, expected, observed); | ||
| } | ||
| function unexpected_empty_element(f, i, length) { | ||
| if (i < length) { | ||
| return missing_element(i, length); | ||
| } else { | ||
| return index_out_of_bounds(f, i, length); | ||
| } | ||
| } | ||
| function empty_dynarray(f) { | ||
@@ -413,35 +490,28 @@ return Curry._1(Stdlib__Printf.ksprintf(Stdlib.invalid_arg, { | ||
| function check_same_length(f, a, length) { | ||
| const length_a = a.length; | ||
| if (length !== length_a) { | ||
| return Curry._3(Stdlib__Printf.ksprintf(Stdlib.invalid_arg, { | ||
| TAG: /* Format */ 0, | ||
| _0: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: "Dynarray.", | ||
| function different_lengths(f, length1, length2) { | ||
| return Curry._3(Stdlib__Printf.ksprintf(Stdlib.invalid_arg, { | ||
| TAG: /* Format */ 0, | ||
| _0: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: "Dynarray.", | ||
| _1: { | ||
| TAG: /* String */ 2, | ||
| _0: /* No_padding */ 0, | ||
| _1: { | ||
| TAG: /* String */ 2, | ||
| _0: /* No_padding */ 0, | ||
| TAG: /* String_literal */ 11, | ||
| _0: ": array length mismatch: ", | ||
| _1: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: ": a length change from ", | ||
| _1: { | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: " to ", | ||
| _1: { | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: " occurred during iteration", | ||
| _1: /* End_of_format */ 0 | ||
| } | ||
| } | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: { | ||
| TAG: /* String_literal */ 11, | ||
| _0: " <> ", | ||
| _1: { | ||
| TAG: /* Int */ 4, | ||
| _0: /* Int_d */ 0, | ||
| _1: /* No_padding */ 0, | ||
| _2: /* No_precision */ 0, | ||
| _3: /* End_of_format */ 0 | ||
| } | ||
@@ -451,5 +521,12 @@ } | ||
| } | ||
| }, | ||
| _1: "Dynarray.%s: a length change from %d to %d occurred during iteration" | ||
| }), f, length, length_a); | ||
| } | ||
| }, | ||
| _1: "Dynarray.%s: array length mismatch: %d <> %d" | ||
| }), f, length1, length2); | ||
| } | ||
| function check_same_length(f, a, length) { | ||
| const length_a = a.length; | ||
| if (length !== length_a) { | ||
| return length_change_during_iteration(f, length, length_a); | ||
| } | ||
@@ -496,9 +573,3 @@ | ||
| if (v === a.dummy) { | ||
| let f = "get"; | ||
| let length = a.length; | ||
| if (i < length) { | ||
| return missing_element(i, length); | ||
| } else { | ||
| return index_out_of_bounds(f, i, length); | ||
| } | ||
| return unexpected_empty_element("get", i, a.length); | ||
| } else { | ||
@@ -527,3 +598,3 @@ return v; | ||
| function copy$1(param) { | ||
| function copy(param) { | ||
| const length = param.length; | ||
@@ -666,4 +737,4 @@ const arr = param.arr; | ||
| _1: [ | ||
| "jscomp/stdlib/dynarray.ml", | ||
| 606, | ||
| "dynarray.cppo.ml", | ||
| 639, | ||
| 4 | ||
@@ -679,4 +750,4 @@ ] | ||
| _1: [ | ||
| "jscomp/stdlib/dynarray.ml", | ||
| 611, | ||
| "dynarray.cppo.ml", | ||
| 644, | ||
| 4 | ||
@@ -692,4 +763,4 @@ ] | ||
| _1: [ | ||
| "jscomp/stdlib/dynarray.ml", | ||
| 612, | ||
| "dynarray.cppo.ml", | ||
| 645, | ||
| 4 | ||
@@ -1109,4 +1180,78 @@ ] | ||
| function exists2(p, a1, a2) { | ||
| const length1 = a1.length; | ||
| const arr1 = a1.arr; | ||
| const length2 = a2.length; | ||
| const arr2 = a2.arr; | ||
| const capacity = arr1.length; | ||
| if (length1 > capacity) { | ||
| invalid_length(length1, capacity); | ||
| } | ||
| const capacity$1 = arr2.length; | ||
| if (length2 > capacity$1) { | ||
| invalid_length(length2, capacity$1); | ||
| } | ||
| if (length1 !== length2) { | ||
| different_lengths("exists2", length1, length2); | ||
| } | ||
| const loop = function (p, arr1, dummy1, arr2, dummy2, _i, length) { | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === length) { | ||
| return false; | ||
| } | ||
| const v = arr1[i]; | ||
| const v$1 = arr2[i]; | ||
| if (Curry._2(p, v === dummy1 ? missing_element(i, length) : v, v$1 === dummy2 ? missing_element(i, length) : v$1)) { | ||
| return true; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| }; | ||
| const res = loop(p, arr1, a1.dummy, arr2, a2.dummy, 0, length1); | ||
| check_same_length("exists2", a1, length1); | ||
| check_same_length("exists2", a2, length2); | ||
| return res; | ||
| } | ||
| function for_all2(p, a1, a2) { | ||
| const length1 = a1.length; | ||
| const arr1 = a1.arr; | ||
| const length2 = a2.length; | ||
| const arr2 = a2.arr; | ||
| const capacity = arr1.length; | ||
| if (length1 > capacity) { | ||
| invalid_length(length1, capacity); | ||
| } | ||
| const capacity$1 = arr2.length; | ||
| if (length2 > capacity$1) { | ||
| invalid_length(length2, capacity$1); | ||
| } | ||
| if (length1 !== length2) { | ||
| different_lengths("for_all2", length1, length2); | ||
| } | ||
| const loop = function (p, arr1, dummy1, arr2, dummy2, _i, length) { | ||
| while (true) { | ||
| const i = _i; | ||
| if (i === length) { | ||
| return true; | ||
| } | ||
| const v = arr1[i]; | ||
| const v$1 = arr2[i]; | ||
| if (!Curry._2(p, v === dummy1 ? missing_element(i, length) : v, v$1 === dummy2 ? missing_element(i, length) : v$1)) { | ||
| return false; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| }; | ||
| const res = loop(p, arr1, a1.dummy, arr2, a2.dummy, 0, length1); | ||
| check_same_length("for_all2", a1, length1); | ||
| check_same_length("for_all2", a2, length2); | ||
| return res; | ||
| } | ||
| function filter(f, a) { | ||
| const b = create(undefined); | ||
| const b = create(); | ||
| iter_("filter", (function (x) { | ||
@@ -1122,3 +1267,3 @@ if (Curry._1(f, x)) { | ||
| function filter_map(f, a) { | ||
| const b = create(undefined); | ||
| const b = create(); | ||
| iter_("filter_map", (function (x) { | ||
@@ -1384,3 +1529,3 @@ const y = Curry._1(f, x); | ||
| const dummy = global_dummy._0; | ||
| const arr = Curry._2(Dummy_Array.copy, a, dummy); | ||
| const arr = Curry._2(Dummy_Array.copy_from_array, a, dummy); | ||
| return { | ||
@@ -1417,3 +1562,3 @@ length: length, | ||
| const dummy = global_dummy._0; | ||
| const arr = Curry._2(Dummy_Array.unsafe_nocopy, a, dummy); | ||
| const arr = Curry._2(Dummy_Array.unsafe_nocopy_from_array, a, dummy); | ||
| return { | ||
@@ -1447,3 +1592,3 @@ length: length, | ||
| function of_seq(seq) { | ||
| const init = create(undefined); | ||
| const init = create(); | ||
| append_seq(init, seq); | ||
@@ -1561,2 +1706,30 @@ return init; | ||
| function unsafe_to_iarray(capacity, f) { | ||
| const a = create(); | ||
| set_capacity(a, capacity); | ||
| Curry._1(f, a); | ||
| const length = a.length; | ||
| const arr = a.arr; | ||
| reset(a); | ||
| const capacity$1 = arr.length; | ||
| const capacity$2 = arr.length; | ||
| if (length > capacity$2) { | ||
| invalid_length(length, capacity$2); | ||
| } | ||
| const values = length === capacity$1 ? arr : Curry._2(Dummy_Array.prefix, arr, length); | ||
| let tmp; | ||
| try { | ||
| tmp = Curry._2(Dummy_Array.unsafe_nocopy_to_array, values, a.dummy); | ||
| } | ||
| catch (raw_i){ | ||
| const i = Caml_js_exceptions.internalToOCamlException(raw_i); | ||
| if (i.MEL_EXN_ID === Dummy_Array.Dummy_found) { | ||
| tmp = Curry._2(missing_element, i._1, length); | ||
| } else { | ||
| throw i; | ||
| } | ||
| } | ||
| return tmp; | ||
| } | ||
| export { | ||
@@ -1572,3 +1745,3 @@ create, | ||
| find_last, | ||
| copy$1 as copy, | ||
| copy, | ||
| add_last, | ||
@@ -1596,2 +1769,4 @@ append_array, | ||
| for_all, | ||
| exists2, | ||
| for_all2, | ||
| mem, | ||
@@ -1620,3 +1795,4 @@ memq, | ||
| reset, | ||
| unsafe_to_iarray, | ||
| } | ||
| /* global_dummy Not a pure module */ |
+28
-0
| // Generated by Melange | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
| import * as Caml_option from "melange.js/caml_option.js"; | ||
@@ -36,2 +37,22 @@ import * as Curry from "melange.js/curry.js"; | ||
| function get_left(v) { | ||
| if (v.TAG === /* Left */ 0) { | ||
| return v._0; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Either.t is Right _" | ||
| }); | ||
| } | ||
| function get_right(v) { | ||
| if (v.TAG !== /* Left */ 0) { | ||
| return v._0; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Either.t is Left _" | ||
| }); | ||
| } | ||
| function find_left(v) { | ||
@@ -96,2 +117,6 @@ if (v.TAG === /* Left */ 0) { | ||
| function retract(v) { | ||
| return v._0; | ||
| } | ||
| function equal(left, right, e1, e2) { | ||
@@ -134,2 +159,4 @@ if (e1.TAG === /* Left */ 0) { | ||
| is_right, | ||
| get_left, | ||
| get_right, | ||
| find_left, | ||
@@ -141,2 +168,3 @@ find_right, | ||
| fold, | ||
| retract, | ||
| iter, | ||
@@ -143,0 +171,0 @@ for_all, |
+45
-66
@@ -7,2 +7,3 @@ // Generated by Melange | ||
| import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; | ||
| import * as Caml_float from "melange.js/caml_float.js"; | ||
| import * as Caml_hash from "melange.js/caml_hash.js"; | ||
@@ -36,3 +37,3 @@ import * as Caml_int64 from "melange.js/caml_int64.js"; | ||
| function is_integer(x) { | ||
| if (x === Caml_external_polyfill.resolve("caml_trunc_float")(x)) { | ||
| if (x === Math.trunc(x)) { | ||
| return is_finite(x); | ||
@@ -57,3 +58,3 @@ } else { | ||
| function min(x, y) { | ||
| if (y > x || y >= 0 && x < 0) { | ||
| if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| if (y !== y) { | ||
@@ -72,3 +73,3 @@ return y; | ||
| function max(x, y) { | ||
| if (y > x || y >= 0 && x < 0) { | ||
| if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| if (x !== x) { | ||
@@ -92,3 +93,3 @@ return x; | ||
| ]; | ||
| } else if (y > x || y >= 0 && x < 0) { | ||
| } else if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| return [ | ||
@@ -107,3 +108,3 @@ x, | ||
| function min_num(x, y) { | ||
| if (y > x || y >= 0 && x < 0) { | ||
| if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| if (x !== x) { | ||
@@ -122,3 +123,3 @@ return y; | ||
| function max_num(x, y) { | ||
| if (y > x || y >= 0 && x < 0) { | ||
| if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| if (y !== y) { | ||
@@ -147,3 +148,3 @@ return x; | ||
| ]; | ||
| } else if (y > x || y >= 0 && x < 0) { | ||
| } else if (y > x || !Caml_float.caml_signbit_float(y) && Caml_float.caml_signbit_float(x)) { | ||
| return [ | ||
@@ -229,57 +230,2 @@ x, | ||
| function ensure_ge(x, y) { | ||
| if (x >= y) { | ||
| return x; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Float.Array.concat" | ||
| }); | ||
| } | ||
| function sum_lengths(_acc, _param) { | ||
| while (true) { | ||
| const param = _param; | ||
| const acc = _acc; | ||
| if (!param) { | ||
| return acc; | ||
| } | ||
| _param = param.tl; | ||
| _acc = ensure_ge(param.hd.length + acc | 0, acc); | ||
| continue; | ||
| }; | ||
| } | ||
| function concat(l) { | ||
| const len = sum_lengths(0, l); | ||
| const result = Caml_array.make_float(len); | ||
| const loop = function (_l, _i) { | ||
| while (true) { | ||
| const i = _i; | ||
| const l = _l; | ||
| if (l) { | ||
| const hd = l.hd; | ||
| const hlen = hd.length; | ||
| Caml_external_polyfill.resolve("caml_floatarray_blit")(hd, 0, result, i, hlen); | ||
| _i = i + hlen | 0; | ||
| _l = l.tl; | ||
| continue; | ||
| } | ||
| if (i === len) { | ||
| return; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError("Assert_failure", { | ||
| MEL_EXN_ID: "Assert_failure", | ||
| _1: [ | ||
| "float.cppo.ml", | ||
| 313, | ||
| 14 | ||
| ] | ||
| }); | ||
| }; | ||
| }; | ||
| loop(l, 0); | ||
| return result; | ||
| } | ||
| function sub(a, ofs, len) { | ||
@@ -344,2 +290,34 @@ check(a, ofs, len, "Float.Array.sub"); | ||
| function equal$1(eq, a, b) { | ||
| if (a.length !== b.length) { | ||
| return false; | ||
| } | ||
| let i = 0; | ||
| const len = a.length; | ||
| while (i < len && Curry._2(eq, a[i], b[i])) { | ||
| i = i + 1 | 0; | ||
| }; | ||
| return i === len; | ||
| } | ||
| function compare(cmp, a, b) { | ||
| const len_a = a.length; | ||
| const len_b = b.length; | ||
| const diff = len_a - len_b | 0; | ||
| if (diff !== 0) { | ||
| if (diff < 0) { | ||
| return -1; | ||
| } else { | ||
| return 1; | ||
| } | ||
| } | ||
| let i = 0; | ||
| let c = 0; | ||
| while (i < len_a && c === 0) { | ||
| c = Curry._2(cmp, a[i], b[i]); | ||
| i = i + 1 | 0; | ||
| }; | ||
| return c; | ||
| } | ||
| function iter(f, a) { | ||
@@ -638,3 +616,3 @@ for (let i = 0, i_finish = a.length; i < i_finish; ++i) { | ||
| "float.cppo.ml", | ||
| 560, | ||
| 555, | ||
| 6 | ||
@@ -863,3 +841,3 @@ ] | ||
| const compare = Caml.caml_float_compare; | ||
| const compare$1 = Caml.caml_float_compare; | ||
@@ -890,3 +868,2 @@ function Array_length(prim) { | ||
| append: append, | ||
| concat: concat, | ||
| sub: sub, | ||
@@ -898,2 +875,4 @@ copy: copy, | ||
| of_list: of_list, | ||
| equal: equal$1, | ||
| compare: compare, | ||
| iter: iter, | ||
@@ -949,3 +928,3 @@ iteri: iteri, | ||
| to_string, | ||
| compare, | ||
| compare$1 as compare, | ||
| equal, | ||
@@ -952,0 +931,0 @@ min, |
+251
-18
| // Generated by Melange | ||
| import * as Caml from "melange.js/caml.js"; | ||
| import * as Caml_bytes from "melange.js/caml_bytes.js"; | ||
@@ -12,2 +13,3 @@ import * as Caml_exceptions from "melange.js/caml_exceptions.js"; | ||
| import * as CamlinternalFormat from "./camlinternalFormat.js"; | ||
| import * as CamlinternalFormatBasics from "./camlinternalFormatBasics.js"; | ||
| import * as Curry from "melange.js/curry.js"; | ||
@@ -47,2 +49,6 @@ import * as Stdlib from "./stdlib.js"; | ||
| function pp_string_width(state, s) { | ||
| return Curry._3(state.pp_out_width, s, 0, s.length); | ||
| } | ||
| function pp_output_substring(state, pos, len, s) { | ||
@@ -52,2 +58,6 @@ Curry._3(state.pp_out_string, s, pos, len); | ||
| function pp_substring_width(state, pos, len, s) { | ||
| return Curry._3(state.pp_out_width, s, pos, len); | ||
| } | ||
| function format_pp_text(state, size, text) { | ||
@@ -61,3 +71,3 @@ state.pp_space_left = state.pp_space_left - size | 0; | ||
| if (s !== "") { | ||
| return format_pp_text(state, s.length, s); | ||
| return format_pp_text(state, pp_string_width(state, s), s); | ||
| } | ||
@@ -204,3 +214,3 @@ | ||
| case /* Pp_hovbox */ 3 : | ||
| if ((size + before.length | 0) > state.pp_space_left) { | ||
| if ((size + pp_string_width(state, before) | 0) > state.pp_space_left) { | ||
| return break_new_line(state, breaks, width); | ||
@@ -211,3 +221,3 @@ } else { | ||
| case /* Pp_box */ 4 : | ||
| if (state.pp_is_new_line || !((size + before.length | 0) > state.pp_space_left || state.pp_current_indent > ((state.pp_margin - width | 0) + breaks[1] | 0))) { | ||
| if (state.pp_is_new_line || !((size + pp_string_width(state, before) | 0) > state.pp_space_left || state.pp_current_indent > ((state.pp_margin - width | 0) + breaks[1] | 0))) { | ||
| return break_same_line(state, fits); | ||
@@ -301,7 +311,13 @@ } else { | ||
| } | ||
| Stdlib__Queue.take(state.pp_queue); | ||
| const size$1 = size >= 0 ? size : 1000000010; | ||
| format_pp_token(state, size$1, match.token); | ||
| state.pp_left_total = match.length + state.pp_left_total | 0; | ||
| continue; | ||
| const match$1 = Stdlib__Queue.take_opt(state.pp_queue); | ||
| if (match$1 !== undefined) { | ||
| const size$1 = size >= 0 ? size : 1000000010; | ||
| format_pp_token(state, size$1, match.token); | ||
| state.pp_left_total = match.length + state.pp_left_total | 0; | ||
| continue; | ||
| } | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "Format: Unsynchronized access to formatter" | ||
| }); | ||
| }; | ||
@@ -397,3 +413,4 @@ } | ||
| let s = state.pp_ellipsis; | ||
| return enqueue_string_as(state, s.length, s); | ||
| const size = pp_string_width(state, s); | ||
| return enqueue_string_as(state, size, s); | ||
| } else { | ||
@@ -403,5 +420,5 @@ return; | ||
| } | ||
| const size = -state.pp_right_total | 0; | ||
| const size$1 = -state.pp_right_total | 0; | ||
| const elem = { | ||
| size: size, | ||
| size: size$1, | ||
| token: { | ||
@@ -552,3 +569,3 @@ TAG: /* Pp_begin */ 4, | ||
| function pp_print_string(state, s) { | ||
| pp_print_as(state, s.length, s); | ||
| pp_print_as(state, pp_string_width(state, s), s); | ||
| } | ||
@@ -574,3 +591,4 @@ | ||
| function pp_print_substring(pos, len, state, s) { | ||
| pp_print_substring_as(pos, len, state, len, s); | ||
| const width = pp_substring_width(state, pos, len, s); | ||
| pp_print_substring_as(pos, len, state, width, s); | ||
| } | ||
@@ -664,3 +682,3 @@ | ||
| }; | ||
| const length = (fits[0].length + fits[1] | 0) + fits[2].length | 0; | ||
| const length = (pp_string_width(state, fits[0]) + fits[1] | 0) + pp_string_width(state, fits[2]) | 0; | ||
| const elem = { | ||
@@ -910,2 +928,3 @@ size: size, | ||
| state.pp_out_string = param.out_string; | ||
| state.pp_out_width = param.out_width; | ||
| state.pp_out_flush = param.out_flush; | ||
@@ -920,2 +939,3 @@ state.pp_out_newline = param.out_newline; | ||
| out_string: state.pp_out_string, | ||
| out_width: state.pp_out_width, | ||
| out_flush: state.pp_out_flush, | ||
@@ -1003,2 +1023,24 @@ out_newline: state.pp_out_newline, | ||
| function utf_8_scalar_width(s, pos, len) { | ||
| let _count = 0; | ||
| let _current = pos; | ||
| let stop = pos + len | 0; | ||
| while (true) { | ||
| const current = _current; | ||
| const count = _count; | ||
| if (current >= stop) { | ||
| return count; | ||
| } | ||
| const decode = Stdlib__Bytes.get_utf_8_uchar(Caml_bytes.bytes_of_string(s), current); | ||
| const advance = (decode >>> 24) & 7; | ||
| _current = current + advance | 0; | ||
| _count = count + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| function ascii_width(param, param$1, len) { | ||
| return len; | ||
| } | ||
| function pp_make_formatter(f, g, h, i, j) { | ||
@@ -1059,2 +1101,3 @@ const pp_queue = { | ||
| pp_out_string: f, | ||
| pp_out_width: utf_8_scalar_width, | ||
| pp_out_flush: g, | ||
@@ -1591,7 +1634,7 @@ pp_out_newline: h, | ||
| } else { | ||
| flush(undefined); | ||
| flush(); | ||
| pp_print_break(ppf, 1, 0); | ||
| } | ||
| } else { | ||
| flush(undefined); | ||
| flush(); | ||
| pp_force_newline(ppf, undefined); | ||
@@ -1601,3 +1644,3 @@ } | ||
| if (left.contents !== len) { | ||
| return flush(undefined); | ||
| return flush(); | ||
| } | ||
@@ -1607,2 +1650,187 @@ | ||
| function format_text(fmt6) { | ||
| const skip_and_count_whites = function (_spaces, _newlines, len, s, _pos) { | ||
| while (true) { | ||
| const pos = _pos; | ||
| const newlines = _newlines; | ||
| const spaces = _spaces; | ||
| if (pos >= len) { | ||
| return [ | ||
| pos, | ||
| spaces, | ||
| newlines | ||
| ]; | ||
| } | ||
| const match = Caml_string.get(s, pos); | ||
| if (match !== 10) { | ||
| if (match !== 32) { | ||
| return [ | ||
| pos, | ||
| spaces, | ||
| newlines | ||
| ]; | ||
| } | ||
| _pos = 1 + pos | 0; | ||
| _spaces = 1 + spaces | 0; | ||
| continue; | ||
| } | ||
| _pos = 1 + pos | 0; | ||
| _newlines = 1 + newlines | 0; | ||
| continue; | ||
| }; | ||
| }; | ||
| const cons_dps = function (_dst, _offset, _repeat, $$break, len, s, pos, fmt) { | ||
| while (true) { | ||
| const dst = _dst; | ||
| const offset = _offset; | ||
| const repeat = _repeat; | ||
| if (repeat === 0) { | ||
| if (pos >= len) { | ||
| dst[offset] = fmt; | ||
| return; | ||
| } | ||
| const space = Stdlib__String.index_from_opt(s, pos, /* ' ' */32); | ||
| const newline = Stdlib__String.index_from_opt(s, pos, /* '\n' */10); | ||
| const first = space !== undefined ? ( | ||
| newline !== undefined ? ( | ||
| space < newline ? space : newline | ||
| ) : space | ||
| ) : newline; | ||
| if (first === undefined) { | ||
| dst[offset] = { | ||
| TAG: /* String_literal */ 11, | ||
| _0: Stdlib__String.sub(s, pos, len - pos | 0), | ||
| _1: fmt | ||
| }; | ||
| return; | ||
| } | ||
| const before = Stdlib__String.sub(s, pos, first - pos | 0); | ||
| const match = skip_and_count_whites(0, 0, len, s, first); | ||
| const newlines = match[2]; | ||
| let match$1; | ||
| let exit = 0; | ||
| if (newlines === 0 || newlines === 1) { | ||
| exit = 1; | ||
| } else { | ||
| match$1 = [ | ||
| newlines, | ||
| /* Force_newline */ 3 | ||
| ]; | ||
| } | ||
| if (exit === 1) { | ||
| match$1 = [ | ||
| 1, | ||
| { | ||
| TAG: /* Break */ 0, | ||
| _0: "", | ||
| _1: Caml.caml_int_max(match[1], 1), | ||
| _2: 0 | ||
| } | ||
| ]; | ||
| } | ||
| const block = { | ||
| TAG: /* String_literal */ 11, | ||
| _0: before, | ||
| _1: 24029 | ||
| }; | ||
| dst[offset] = block; | ||
| return cons_dps(block, "_1", match$1[0], match$1[1], len, s, match[0], fmt); | ||
| } | ||
| const block$1 = { | ||
| TAG: /* Formatting_lit */ 17, | ||
| _0: $$break, | ||
| _1: 24029 | ||
| }; | ||
| dst[offset] = block$1; | ||
| _repeat = repeat - 1 | 0; | ||
| _offset = "_1"; | ||
| _dst = block$1; | ||
| continue; | ||
| }; | ||
| }; | ||
| const concat = function (s, fmt) { | ||
| if (s.NAME === "Char") { | ||
| const c = s.VAL; | ||
| if (c !== 10 && c !== 32) { | ||
| return { | ||
| TAG: /* Char_literal */ 12, | ||
| _0: c, | ||
| _1: fmt | ||
| }; | ||
| } else { | ||
| let spaces = 1; | ||
| return { | ||
| TAG: /* Formatting_lit */ 17, | ||
| _0: { | ||
| TAG: /* Break */ 0, | ||
| _0: "", | ||
| _1: spaces, | ||
| _2: 0 | ||
| }, | ||
| _1: fmt | ||
| }; | ||
| } | ||
| } | ||
| const s$1 = s.VAL; | ||
| let len = s$1.length; | ||
| let pos = 0; | ||
| if (pos >= len) { | ||
| return fmt; | ||
| } | ||
| const space = Stdlib__String.index_from_opt(s$1, pos, /* ' ' */32); | ||
| const newline = Stdlib__String.index_from_opt(s$1, pos, /* '\n' */10); | ||
| const first = space !== undefined ? ( | ||
| newline !== undefined ? ( | ||
| space < newline ? space : newline | ||
| ) : space | ||
| ) : newline; | ||
| if (first === undefined) { | ||
| return { | ||
| TAG: /* String_literal */ 11, | ||
| _0: Stdlib__String.sub(s$1, pos, len - pos | 0), | ||
| _1: fmt | ||
| }; | ||
| } | ||
| const before = Stdlib__String.sub(s$1, pos, first - pos | 0); | ||
| const match = skip_and_count_whites(0, 0, len, s$1, first); | ||
| const newlines = match[2]; | ||
| let match$1; | ||
| let exit = 0; | ||
| if (newlines === 0 || newlines === 1) { | ||
| exit = 1; | ||
| } else { | ||
| match$1 = [ | ||
| newlines, | ||
| /* Force_newline */ 3 | ||
| ]; | ||
| } | ||
| if (exit === 1) { | ||
| match$1 = [ | ||
| 1, | ||
| { | ||
| TAG: /* Break */ 0, | ||
| _0: "", | ||
| _1: Caml.caml_int_max(match[1], 1), | ||
| _2: 0 | ||
| } | ||
| ]; | ||
| } | ||
| const block = { | ||
| TAG: /* String_literal */ 11, | ||
| _0: before, | ||
| _1: 24029 | ||
| }; | ||
| cons_dps(block, "_1", match$1[0], match$1[1], len, s$1, match[0], fmt); | ||
| return block; | ||
| }; | ||
| const fmt = CamlinternalFormatBasics.string_concat_map({ | ||
| f: concat | ||
| }, fmt6._0); | ||
| return { | ||
| TAG: /* Format */ 0, | ||
| _0: fmt, | ||
| _1: CamlinternalFormat.string_of_fmt(fmt) | ||
| }; | ||
| } | ||
| function pp_print_option(noneOpt, pp_v, ppf, v) { | ||
@@ -2055,3 +2283,3 @@ const none = noneOpt !== undefined ? noneOpt : (function (param, param$1) { | ||
| Stdlib__Domain.before_first_spawn(function (param) { | ||
| flush_standard_formatters(undefined); | ||
| flush_standard_formatters(); | ||
| const fs = pp_get_formatter_out_functions(std_formatter, undefined); | ||
@@ -2062,2 +2290,3 @@ pp_set_formatter_out_functions(std_formatter, { | ||
| }), | ||
| out_width: fs.out_width, | ||
| out_flush: (function (param) { | ||
@@ -2075,2 +2304,3 @@ return buffered_out_flush(Stdlib.stdout, std_buf_key, param); | ||
| }), | ||
| out_width: fs$1.out_width, | ||
| out_flush: (function (param) { | ||
@@ -2197,2 +2427,4 @@ return buffered_out_flush(Stdlib.stderr, err_buf_key, param); | ||
| get_formatter_out_functions, | ||
| utf_8_scalar_width, | ||
| ascii_width, | ||
| pp_set_formatter_stag_functions, | ||
@@ -2228,2 +2460,3 @@ set_formatter_stag_functions, | ||
| pp_print_text, | ||
| format_text, | ||
| pp_print_option, | ||
@@ -2230,0 +2463,0 @@ pp_print_result, |
+2
-2
@@ -57,7 +57,7 @@ // Generated by Melange | ||
| let work_bt; | ||
| finally_no_exn(undefined); | ||
| finally_no_exn(); | ||
| Caml_external_polyfill.resolve("caml_restore_raw_backtrace")(work_exn, work_bt); | ||
| throw work_exn; | ||
| } | ||
| finally_no_exn(undefined); | ||
| finally_no_exn(); | ||
| return result; | ||
@@ -64,0 +64,0 @@ } |
+16
-2
@@ -21,3 +21,3 @@ // Generated by Melange | ||
| function print_stat(c) { | ||
| const st = Caml_external_polyfill.resolve("caml_gc_stat")(undefined); | ||
| const st = Caml_external_polyfill.resolve("caml_gc_stat")(); | ||
| Curry._1(Stdlib__Printf.fprintf(c, { | ||
@@ -430,3 +430,3 @@ TAG: /* Format */ 0, | ||
| function allocated_bytes(param) { | ||
| const match = Caml_external_polyfill.resolve("caml_gc_counters")(undefined); | ||
| const match = Caml_external_polyfill.resolve("caml_gc_counters")(); | ||
| return (match[0] + match[2] - match[1]) * (Stdlib__Sys.word_size / 8 | 0); | ||
@@ -462,2 +462,15 @@ } | ||
| function string_of_allocation_source(param) { | ||
| switch (param) { | ||
| case /* Normal */ 0 : | ||
| return "Normal"; | ||
| case /* Marshal */ 1 : | ||
| return "Marshal"; | ||
| case /* Custom */ 2 : | ||
| return "Custom"; | ||
| case /* Map_file */ 3 : | ||
| return "Map_file"; | ||
| } | ||
| } | ||
| function null_tracker_alloc_minor(param) { | ||
@@ -517,2 +530,3 @@ | ||
| const Memprof = { | ||
| string_of_allocation_source: string_of_allocation_source, | ||
| null_tracker: null_tracker, | ||
@@ -519,0 +533,0 @@ start: start, |
+4
-4
@@ -90,3 +90,3 @@ // Generated by Melange | ||
| Stdlib.really_input(ic, buf, pos, len); | ||
| return Caml_option.some(undefined); | ||
| return Caml_option.some(); | ||
| } | ||
@@ -176,3 +176,3 @@ catch (raw_exn){ | ||
| } | ||
| const initial_size$1 = initial_size < 0 ? 65536 : initial_size; | ||
| const initial_size$1 = initial_size < 0 ? Stdlib__Sys.io_buffer_size : initial_size; | ||
| const initial_size$2 = initial_size$1 <= Stdlib__Sys.max_string_length ? initial_size$1 : Stdlib__Sys.max_string_length; | ||
@@ -195,3 +195,3 @@ const buf = Caml_bytes.caml_create_bytes(initial_size$2); | ||
| } | ||
| const buf$1 = ensure(buf, nread, 65537); | ||
| const buf$1 = ensure(buf, nread, Stdlib__Sys.io_buffer_size + 1 | 0); | ||
| Caml_bytes.set(buf$1, nread, c); | ||
@@ -203,3 +203,3 @@ let _buf = buf$1; | ||
| const buf$2 = _buf; | ||
| const buf$3 = ensure(buf$2, ofs, 65536); | ||
| const buf$3 = ensure(buf$2, ofs, Stdlib__Sys.io_buffer_size); | ||
| const rem = buf$3.length - ofs | 0; | ||
@@ -206,0 +206,0 @@ const r = read_upto(ic, buf$3, ofs, rem); |
+48
-44
@@ -31,2 +31,9 @@ // Generated by Melange | ||
| function singleton(a) { | ||
| return { | ||
| hd: a, | ||
| tl: /* [] */ 0 | ||
| }; | ||
| } | ||
| function hd(param) { | ||
@@ -1163,44 +1170,40 @@ if (param) { | ||
| }; | ||
| if (n < 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "List.take" | ||
| }); | ||
| } | ||
| if (n === 0) { | ||
| if (n <= 0) { | ||
| return /* [] */ 0; | ||
| } else { | ||
| if (n === 0) { | ||
| return /* [] */ 0; | ||
| } | ||
| if (!l) { | ||
| return /* [] */ 0; | ||
| } | ||
| const block = { | ||
| hd: l.hd, | ||
| tl: 24029 | ||
| }; | ||
| aux_dps(block, "tl", n - 1 | 0, l.tl); | ||
| return block; | ||
| } | ||
| if (!l) { | ||
| return /* [] */ 0; | ||
| } | ||
| const block = { | ||
| hd: l.hd, | ||
| tl: 24029 | ||
| }; | ||
| aux_dps(block, "tl", n - 1 | 0, l.tl); | ||
| return block; | ||
| } | ||
| function drop(n, l) { | ||
| if (n < 0) { | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: "List.drop" | ||
| }); | ||
| if (n <= 0) { | ||
| return l; | ||
| } else { | ||
| let _i = 0; | ||
| let _rest = l; | ||
| while (true) { | ||
| const rest = _rest; | ||
| const i = _i; | ||
| if (!rest) { | ||
| return rest; | ||
| } | ||
| if (i >= n) { | ||
| return rest; | ||
| } | ||
| _rest = rest.tl; | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
| let _i = 0; | ||
| let _rest = l; | ||
| while (true) { | ||
| const rest = _rest; | ||
| const i = _i; | ||
| if (!rest) { | ||
| return rest; | ||
| } | ||
| if (i >= n) { | ||
| return rest; | ||
| } | ||
| _rest = rest.tl; | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
@@ -1819,9 +1822,9 @@ | ||
| if (c === 0) { | ||
| const c$1 = Curry._2(cmp, x2, x3); | ||
| const c$1 = Curry._2(cmp, x1, x3); | ||
| s = c$1 === 0 ? ({ | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: /* [] */ 0 | ||
| }) : ( | ||
| c$1 < 0 ? ({ | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: { | ||
@@ -1834,3 +1837,3 @@ hd: x3, | ||
| tl: { | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: /* [] */ 0 | ||
@@ -2006,9 +2009,9 @@ } | ||
| if (c === 0) { | ||
| const c$1 = Curry._2(cmp, x2, x3); | ||
| const c$1 = Curry._2(cmp, x1, x3); | ||
| s = c$1 === 0 ? ({ | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: /* [] */ 0 | ||
| }) : ( | ||
| c$1 > 0 ? ({ | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: { | ||
@@ -2021,3 +2024,3 @@ hd: x3, | ||
| tl: { | ||
| hd: x2, | ||
| hd: x1, | ||
| tl: /* [] */ 0 | ||
@@ -2377,2 +2380,3 @@ } | ||
| cons, | ||
| singleton, | ||
| hd, | ||
@@ -2379,0 +2383,0 @@ tl, |
+3
-0
@@ -15,2 +15,4 @@ // Generated by Melange | ||
| const singleton = Stdlib__List.singleton; | ||
| const hd = Stdlib__List.hd; | ||
@@ -150,2 +152,3 @@ | ||
| cons, | ||
| singleton, | ||
| hd, | ||
@@ -152,0 +155,0 @@ tl, |
+2
-2
@@ -11,6 +11,6 @@ { | ||
| "name": "melange", | ||
| "version": "5.1.0", | ||
| "version": "6.0.1", | ||
| "dependencies": { | ||
| "melange.js": "5.1.0" | ||
| "melange.js": "6.0.1" | ||
| } | ||
| } |
+4
-4
@@ -95,3 +95,3 @@ // Generated by Melange | ||
| case /* Grow_stacks_1 */ 2 : | ||
| grow_stacks(undefined); | ||
| grow_stacks(); | ||
| _arg = undefined; | ||
@@ -101,3 +101,3 @@ _cmd = /* Stacks_grown_1 */ 2; | ||
| case /* Grow_stacks_2 */ 3 : | ||
| grow_stacks(undefined); | ||
| grow_stacks(); | ||
| _arg = undefined; | ||
@@ -194,7 +194,7 @@ _cmd = /* Stacks_grown_2 */ 3; | ||
| function symbol_start(param) { | ||
| return symbol_start_pos(undefined).pos_cnum; | ||
| return symbol_start_pos().pos_cnum; | ||
| } | ||
| function symbol_end(param) { | ||
| return symbol_end_pos(undefined).pos_cnum; | ||
| return symbol_end_pos().pos_cnum; | ||
| } | ||
@@ -201,0 +201,0 @@ |
+2
-2
@@ -496,3 +496,3 @@ // Generated by Melange | ||
| function get_backtrace(param) { | ||
| return raw_backtrace_to_string(undefined); | ||
| return raw_backtrace_to_string(); | ||
| } | ||
@@ -542,3 +542,3 @@ | ||
| print_raw_backtrace(Stdlib.stderr, raw_backtrace); | ||
| const status = Caml_external_polyfill.resolve("caml_ml_debug_info_status")(undefined); | ||
| const status = Caml_external_polyfill.resolve("caml_ml_debug_info_status")(); | ||
| if (status < 0) { | ||
@@ -545,0 +545,0 @@ console.error(Caml_array.get(errors, Stdlib.abs(status))); |
+2
-2
@@ -58,3 +58,3 @@ // Generated by Melange | ||
| function make_self_init(param) { | ||
| return make(random_seed(undefined)); | ||
| return make(random_seed()); | ||
| } | ||
@@ -311,3 +311,3 @@ | ||
| function self_init(param) { | ||
| full_init$1(random_seed(undefined)); | ||
| full_init$1(random_seed()); | ||
| } | ||
@@ -314,0 +314,0 @@ |
+1
-1
| # melange | ||
| This is the runtime package for the melange library, compatible with | ||
| [Melange](https://melange.re) 5.1.0. | ||
| [Melange](https://melange.re) 6.0.1. | ||
@@ -6,0 +6,0 @@ ## Installation |
+60
-0
@@ -40,2 +40,13 @@ // Generated by Melange | ||
| function get_ok$p(v) { | ||
| if (v.TAG === /* Ok */ 0) { | ||
| return v._0; | ||
| } | ||
| const s = v._0; | ||
| throw new Caml_js_exceptions.MelangeError("Invalid_argument", { | ||
| MEL_EXN_ID: "Invalid_argument", | ||
| _1: s | ||
| }); | ||
| } | ||
| function get_error(e) { | ||
@@ -51,2 +62,13 @@ if (e.TAG !== /* Ok */ 0) { | ||
| function error_to_failure(v) { | ||
| if (v.TAG === /* Ok */ 0) { | ||
| return v._0; | ||
| } | ||
| const s = v._0; | ||
| throw new Caml_js_exceptions.MelangeError("Failure", { | ||
| MEL_EXN_ID: "Failure", | ||
| _1: s | ||
| }); | ||
| } | ||
| function bind(r, f) { | ||
@@ -79,2 +101,20 @@ if (r.TAG === /* Ok */ 0) { | ||
| function product(r0, r1) { | ||
| if (r0.TAG === /* Ok */ 0) { | ||
| if (r1.TAG === /* Ok */ 0) { | ||
| return { | ||
| TAG: /* Ok */ 0, | ||
| _0: [ | ||
| r0._0, | ||
| r1._0 | ||
| ] | ||
| }; | ||
| } else { | ||
| return r1; | ||
| } | ||
| } else { | ||
| return r0; | ||
| } | ||
| } | ||
| function map_error(f, e) { | ||
@@ -99,2 +139,6 @@ if (e.TAG === /* Ok */ 0) { | ||
| function retract(v) { | ||
| return v._0; | ||
| } | ||
| function iter(f, v) { | ||
@@ -187,2 +231,13 @@ if (v.TAG === /* Ok */ 0) { | ||
| function let$plus(r, f) { | ||
| return map(f, r); | ||
| } | ||
| const Syntax = { | ||
| let$star: bind, | ||
| and$star: product, | ||
| let$plus: let$plus, | ||
| and$plus: product | ||
| }; | ||
| export { | ||
@@ -193,8 +248,12 @@ ok, | ||
| get_ok, | ||
| get_ok$p, | ||
| get_error, | ||
| error_to_failure, | ||
| bind, | ||
| join, | ||
| map, | ||
| product, | ||
| map_error, | ||
| fold, | ||
| retract, | ||
| iter, | ||
@@ -209,3 +268,4 @@ iter_error, | ||
| to_seq, | ||
| Syntax, | ||
| } | ||
| /* No side effect */ |
+4
-4
@@ -1225,4 +1225,4 @@ // Generated by Melange | ||
| }; | ||
| const c1 = get_digit(undefined); | ||
| const c2 = get_digit(undefined); | ||
| const c1 = get_digit(); | ||
| const c2 = get_digit(); | ||
| return store_char(width - 2 | 0, ib, char_for_hexadecimal_code(c1, c2)); | ||
@@ -1244,4 +1244,4 @@ default: | ||
| }; | ||
| const c1$1 = get_digit$1(undefined); | ||
| const c2$1 = get_digit$1(undefined); | ||
| const c1$1 = get_digit$1(); | ||
| const c2$1 = get_digit$1(); | ||
| return store_char(width - 2 | 0, ib, char_for_decimal_code(c, c1$1, c2$1)); | ||
@@ -1248,0 +1248,0 @@ } |
+43
-2
@@ -30,2 +30,10 @@ // Generated by Melange | ||
| function singleton(x, param) { | ||
| return { | ||
| TAG: /* Cons */ 0, | ||
| _0: x, | ||
| _1: empty | ||
| }; | ||
| } | ||
| function append(seq1, seq2, param) { | ||
@@ -109,2 +117,33 @@ const match = Curry._1(seq1, undefined); | ||
| function filteri_aux(f, _i, _seq, _param) { | ||
| while (true) { | ||
| const seq = _seq; | ||
| const i = _i; | ||
| const match = Curry._1(seq, undefined); | ||
| if (/* tag */ typeof match === "number" || typeof match === "string") { | ||
| return /* Nil */ 0; | ||
| } | ||
| const next = match._1; | ||
| const x = match._0; | ||
| const i$p = i + 1 | 0; | ||
| if (Curry._2(f, i, x)) { | ||
| return { | ||
| TAG: /* Cons */ 0, | ||
| _0: x, | ||
| _1: (function (param) { | ||
| return filteri_aux(f, i$p, next, param); | ||
| }) | ||
| }; | ||
| } | ||
| _param = undefined; | ||
| _seq = next; | ||
| _i = i$p; | ||
| continue; | ||
| }; | ||
| } | ||
| function filteri(f, seq, param) { | ||
| return filteri_aux(f, 0, seq, undefined); | ||
| } | ||
| function concat(seq, param) { | ||
@@ -783,3 +822,3 @@ const match = Curry._1(seq, undefined); | ||
| function once(xs) { | ||
| const f = function (param) { | ||
| let f = function (param) { | ||
| const match = Curry._1(xs, undefined); | ||
@@ -1048,3 +1087,3 @@ if (/* tag */ typeof match === "number" || typeof match === "string") { | ||
| "jscomp/stdlib/seq.ml", | ||
| 616, | ||
| 629, | ||
| 4 | ||
@@ -1198,2 +1237,3 @@ ] | ||
| cons, | ||
| singleton, | ||
| init, | ||
@@ -1208,2 +1248,3 @@ unfold, | ||
| filter, | ||
| filteri, | ||
| filter_map, | ||
@@ -1210,0 +1251,0 @@ scan, |
+1
-1
@@ -5,3 +5,3 @@ // Generated by Melange | ||
| Stdlib.do_at_exit(undefined); | ||
| Stdlib.do_at_exit(); | ||
| /* Not a pure module */ |
+2
-2
@@ -292,3 +292,3 @@ // Generated by Melange | ||
| function flush_all(param) { | ||
| let _param = Caml_io.caml_ml_out_channels_list(undefined); | ||
| let _param = Caml_io.caml_ml_out_channels_list(); | ||
| while (true) { | ||
@@ -615,3 +615,3 @@ const param$1 = _param; | ||
| function exit(retcode) { | ||
| do_at_exit(undefined); | ||
| do_at_exit(); | ||
| return Caml_sys.caml_sys_exit(retcode); | ||
@@ -618,0 +618,0 @@ } |
+178
-6
| // Generated by Melange | ||
| import * as Caml from "melange.js/caml.js"; | ||
| import * as Caml_array from "melange.js/caml_array.js"; | ||
| import * as Caml_bytes from "melange.js/caml_bytes.js"; | ||
| import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; | ||
| import * as Caml_hash from "melange.js/caml_hash.js"; | ||
| import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; | ||
@@ -10,3 +11,7 @@ import * as Caml_string from "melange.js/caml_string.js"; | ||
| import * as Stdlib from "./stdlib.js"; | ||
| import * as Stdlib__Array from "./array.js"; | ||
| import * as Stdlib__Bytes from "./bytes.js"; | ||
| import * as Stdlib__Int from "./int.js"; | ||
| import * as Stdlib__List from "./list.js"; | ||
| import * as Stdlib__Uchar from "./uchar.js"; | ||
@@ -22,3 +27,7 @@ function make(n, c) { | ||
| function sub(s, ofs, len) { | ||
| return Caml_bytes.bytes_to_string(Stdlib__Bytes.sub(Caml_bytes.bytes_of_string(s), ofs, len)); | ||
| if (ofs === 0 && s.length === len) { | ||
| return s; | ||
| } else { | ||
| return Caml_bytes.bytes_to_string(Stdlib__Bytes.sub(Caml_bytes.bytes_of_string(s), ofs, len)); | ||
| } | ||
| } | ||
@@ -77,2 +86,5 @@ | ||
| } | ||
| if (!l.tl) { | ||
| return l.hd; | ||
| } | ||
| const seplen = sep.length; | ||
@@ -371,3 +383,3 @@ return Caml_bytes.bytes_to_string(unsafe_blits(Caml_bytes.caml_create_bytes(sum_lengths(0, seplen, l)), 0, sep, seplen, l)); | ||
| function hash(x) { | ||
| return Caml_external_polyfill.resolve("caml_string_hash")(0, x); | ||
| return Caml_hash.caml_string_hash(0, x); | ||
| } | ||
@@ -472,2 +484,162 @@ | ||
| function utf_8_uchar_length(s) { | ||
| const slen = s.length; | ||
| let i = 0; | ||
| let ulen = 0; | ||
| while (i < slen) { | ||
| const dec_len = Stdlib__Uchar.utf_8_decode_length_of_byte(s.charCodeAt(i)); | ||
| i = i + ( | ||
| dec_len === 0 ? 1 : dec_len | ||
| ) | 0; | ||
| ulen = ulen + 1 | 0; | ||
| }; | ||
| return ulen; | ||
| } | ||
| function uchar_array_of_utf_8_string(s) { | ||
| const slen = s.length; | ||
| const uchars = Caml_array.make(slen, Stdlib__Uchar.max); | ||
| let k = 0; | ||
| let i = 0; | ||
| while (i < slen) { | ||
| const dec = get_utf_8_uchar(s, i); | ||
| i = i + ((dec >>> 24) & 7) | 0; | ||
| Caml_array.set(uchars, k, dec & 16777215); | ||
| k = k + 1 | 0; | ||
| }; | ||
| return [ | ||
| uchars, | ||
| k | ||
| ]; | ||
| } | ||
| function edit_distance$p(limitOpt, s, param, s1) { | ||
| const limit = limitOpt !== undefined ? limitOpt : Stdlib__Int.max_int; | ||
| const len0 = param[1]; | ||
| const s0 = param[0]; | ||
| if (limit <= 1) { | ||
| if (s === s1) { | ||
| return 0; | ||
| } else { | ||
| return limit; | ||
| } | ||
| } | ||
| const match = uchar_array_of_utf_8_string(s1); | ||
| const len1 = match[1]; | ||
| const s1$1 = match[0]; | ||
| const limit$1 = Stdlib__Int.min(Stdlib__Int.max(len0, len1), limit); | ||
| if (Stdlib__Int.abs(len1 - len0 | 0) >= limit$1) { | ||
| return limit$1; | ||
| } | ||
| const match$1 = len0 > len1 ? [ | ||
| s0, | ||
| s1$1 | ||
| ] : [ | ||
| s1$1, | ||
| s0 | ||
| ]; | ||
| const match$2 = len0 > len1 ? [ | ||
| len0, | ||
| len1 | ||
| ] : [ | ||
| len1, | ||
| len0 | ||
| ]; | ||
| const len1$1 = match$2[1]; | ||
| const loop = function (_row_minus2, _row_minus1, _row, _i, len0, limit, s0, s1) { | ||
| while (true) { | ||
| const i = _i; | ||
| const row = _row; | ||
| const row_minus1 = _row_minus1; | ||
| const row_minus2 = _row_minus2; | ||
| if (i > len0) { | ||
| return Caml_array.get(row_minus1, row_minus1.length - 1 | 0); | ||
| } | ||
| const len1 = row.length - 1 | 0; | ||
| let row_min = Stdlib__Int.max_int; | ||
| Caml_array.set(row, 0, i); | ||
| const jmax = Stdlib__Int.min(len1, (i + limit | 0) - 1 | 0); | ||
| const jmax$1 = jmax < 0 ? len1 : jmax; | ||
| for (let j = Stdlib__Int.max(1, i - limit | 0); j <= jmax$1; ++j) { | ||
| const cost = Caml_array.get(s0, i - 1 | 0) === Caml_array.get(s1, j - 1 | 0) ? 0 : 1; | ||
| const min = Stdlib__Int.min(Caml_array.get(row_minus1, j - 1 | 0) + cost | 0, Stdlib__Int.min(Caml_array.get(row_minus1, j) + 1 | 0, Caml_array.get(row, j - 1 | 0) + 1 | 0)); | ||
| const min$1 = i > 1 && j > 1 && Caml_array.get(s0, i - 1 | 0) === Caml_array.get(s1, j - 2 | 0) && Caml_array.get(s0, i - 2 | 0) === Caml_array.get(s1, j - 1 | 0) ? Stdlib__Int.min(min, Caml_array.get(row_minus2, j - 2 | 0) + cost | 0) : min; | ||
| Caml_array.set(row, j, min$1); | ||
| row_min = Stdlib__Int.min(row_min, min$1); | ||
| } | ||
| if (row_min >= limit) { | ||
| return limit; | ||
| } | ||
| _i = i + 1 | 0; | ||
| _row = row_minus2; | ||
| _row_minus1 = row; | ||
| _row_minus2 = row_minus1; | ||
| continue; | ||
| }; | ||
| }; | ||
| const ignore = limit$1 + 1 | 0; | ||
| const row_minus2 = Caml_array.make(len1$1 + 1 | 0, ignore); | ||
| const row_minus1 = Stdlib__Array.init(len1$1 + 1 | 0, (function (x) { | ||
| return x; | ||
| })); | ||
| const row = Caml_array.make(len1$1 + 1 | 0, ignore); | ||
| const d = loop(row_minus2, row_minus1, row, 1, match$2[0], limit$1, match$1[0], match$1[1]); | ||
| if (d > limit$1) { | ||
| return limit$1; | ||
| } else { | ||
| return d; | ||
| } | ||
| } | ||
| function edit_distance(limit, s0, s1) { | ||
| const us0 = uchar_array_of_utf_8_string(s0); | ||
| return edit_distance$p(limit, s0, us0, s1); | ||
| } | ||
| function default_max_dist(s) { | ||
| const match = utf_8_uchar_length(s); | ||
| if (match >= 3) { | ||
| if (match >= 5) { | ||
| return 2; | ||
| } else { | ||
| return 1; | ||
| } | ||
| } else if (match >= 0) { | ||
| return 0; | ||
| } else { | ||
| return 2; | ||
| } | ||
| } | ||
| function spellcheck(max_distOpt, iter_dict, s) { | ||
| const max_dist = max_distOpt !== undefined ? max_distOpt : default_max_dist; | ||
| const min = { | ||
| contents: Curry._1(max_dist, s) | ||
| }; | ||
| const acc = { | ||
| contents: /* [] */ 0 | ||
| }; | ||
| const us = uchar_array_of_utf_8_string(s); | ||
| Curry._1(iter_dict, (function (param) { | ||
| const d = edit_distance$p(min.contents + 1 | 0, s, us, param); | ||
| if (d === min.contents) { | ||
| acc.contents = { | ||
| hd: param, | ||
| tl: acc.contents | ||
| }; | ||
| return; | ||
| } else if (d < min.contents) { | ||
| min.contents = d; | ||
| acc.contents = { | ||
| hd: param, | ||
| tl: /* [] */ 0 | ||
| }; | ||
| return; | ||
| } else { | ||
| return; | ||
| } | ||
| })); | ||
| return Stdlib__List.rev(acc.contents); | ||
| } | ||
| const empty = ""; | ||
@@ -491,5 +663,3 @@ | ||
| function seeded_hash(prim0, prim1) { | ||
| return Caml_external_polyfill.resolve("caml_string_hash")(prim0, prim1); | ||
| } | ||
| const seeded_hash = Caml_hash.caml_string_hash; | ||
@@ -547,2 +717,4 @@ const get_int64_ne = Caml_bytes.get64; | ||
| is_valid_utf_16le, | ||
| edit_distance, | ||
| spellcheck, | ||
| get_uint8, | ||
@@ -549,0 +721,0 @@ get_int8, |
+6
-0
@@ -101,2 +101,6 @@ // Generated by Melange | ||
| const edit_distance = Stdlib__String.edit_distance; | ||
| const spellcheck = Stdlib__String.spellcheck; | ||
| const get_uint8 = Stdlib__String.get_uint8; | ||
@@ -183,2 +187,4 @@ | ||
| is_valid_utf_16le, | ||
| edit_distance, | ||
| spellcheck, | ||
| get_uint8, | ||
@@ -185,0 +191,0 @@ get_int8, |
+101
-4
@@ -6,6 +6,7 @@ // Generated by Melange | ||
| import * as Caml_sys from "melange.js/caml_sys.js"; | ||
| import * as Stdlib from "./stdlib.js"; | ||
| const executable_name = Caml_sys.caml_sys_executable_name(undefined); | ||
| const executable_name = Caml_sys.caml_sys_executable_name(); | ||
| const os_type = Caml_sys.os_type(undefined); | ||
| const os_type = Caml_sys.os_type(); | ||
@@ -19,5 +20,5 @@ const backend_type = { | ||
| const unix = Caml_sys.os_type(undefined) === "Unix"; | ||
| const unix = Caml_sys.os_type() === "Unix"; | ||
| const win32 = Caml_sys.os_type(undefined) === "Win32"; | ||
| const win32 = Caml_sys.os_type() === "Win32"; | ||
@@ -40,2 +41,86 @@ function getenv_opt(s) { | ||
| function signal_to_string(s) { | ||
| if (s === -1) { | ||
| return "SIGABRT"; | ||
| } else if (s === -2) { | ||
| return "SIGALRM"; | ||
| } else if (s === -3) { | ||
| return "SIGFPE"; | ||
| } else if (s === -4) { | ||
| return "SIGHUP"; | ||
| } else if (s === -5) { | ||
| return "SIGILL"; | ||
| } else if (s === -6) { | ||
| return "SIGINT"; | ||
| } else if (s === -7) { | ||
| return "SIGKILL"; | ||
| } else if (s === -8) { | ||
| return "SIGPIPE"; | ||
| } else if (s === -9) { | ||
| return "SIGQUIT"; | ||
| } else if (s === -10) { | ||
| return "SIGSEGV"; | ||
| } else if (s === -11) { | ||
| return "SIGTERM"; | ||
| } else if (s === -12) { | ||
| return "SIGUSR1"; | ||
| } else if (s === -13) { | ||
| return "SIGUSR2"; | ||
| } else if (s === -14) { | ||
| return "SIGCHLD"; | ||
| } else if (s === -15) { | ||
| return "SIGCONT"; | ||
| } else if (s === -16) { | ||
| return "SIGSTOP"; | ||
| } else if (s === -17) { | ||
| return "SIGTSTP"; | ||
| } else if (s === -18) { | ||
| return "SIGTTIN"; | ||
| } else if (s === -19) { | ||
| return "SIGTTOU"; | ||
| } else if (s === -20) { | ||
| return "SIGVTALRM"; | ||
| } else if (s === -21) { | ||
| return "SIGPROF"; | ||
| } else if (s === -22) { | ||
| return "SIGBUS"; | ||
| } else if (s === -23) { | ||
| return "SIGPOLL"; | ||
| } else if (s === -24) { | ||
| return "SIGSYS"; | ||
| } else if (s === -25) { | ||
| return "SIGTRAP"; | ||
| } else if (s === -26) { | ||
| return "SIGURG"; | ||
| } else if (s === -27) { | ||
| return "SIGXCPU"; | ||
| } else if (s === -28) { | ||
| return "SIGXFSZ"; | ||
| } else if (s === -29) { | ||
| return "SIGIO"; | ||
| } else if (s === -30) { | ||
| return "SIGWINCH"; | ||
| } else if (s < -30) { | ||
| return Stdlib.invalid_arg("Sys.signal_to_string"); | ||
| } else { | ||
| return "SIG(" + (String(s) + ")"); | ||
| } | ||
| } | ||
| function signal_of_int(i) { | ||
| if (i < 0) { | ||
| return Stdlib.invalid_arg("Sys.signal_of_int"); | ||
| } else { | ||
| return Caml_external_polyfill.resolve("caml_sys_rev_convert_signal_number")(i); | ||
| } | ||
| } | ||
| function signal_to_int(i) { | ||
| if (i < -30) { | ||
| return Stdlib.invalid_arg("Sys.signal_to_int"); | ||
| } else { | ||
| return Caml_external_polyfill.resolve("caml_sys_convert_signal_number")(i); | ||
| } | ||
| } | ||
| const Break = /* @__PURE__ */ Caml_exceptions.create("Stdlib.Sys.Break"); | ||
@@ -58,2 +143,4 @@ | ||
| const io_buffer_size = 65536; | ||
| const cygwin = false; | ||
@@ -127,2 +214,6 @@ | ||
| const sigio = -29; | ||
| const sigwinch = -30; | ||
| const ocaml_version = "4.14.0+mel"; | ||
@@ -153,2 +244,3 @@ | ||
| getenv_opt, | ||
| io_buffer_size, | ||
| interactive, | ||
@@ -195,2 +287,7 @@ os_type, | ||
| sigxfsz, | ||
| sigio, | ||
| sigwinch, | ||
| signal_to_string, | ||
| signal_of_int, | ||
| signal_to_int, | ||
| Break, | ||
@@ -197,0 +294,0 @@ catch_break, |
+1
-3
@@ -14,5 +14,3 @@ // Generated by Melange | ||
| function uid(A) { | ||
| return Stdlib__Obj.Extension_constructor.id(Stdlib__Obj.Extension_constructor.of_val({ | ||
| MEL_EXN_ID: A.Id | ||
| })); | ||
| return Stdlib__Obj.Extension_constructor.id(A.Id); | ||
| } | ||
@@ -19,0 +17,0 @@ |
+28
-4
@@ -120,2 +120,22 @@ // Generated by Melange | ||
| function utf_8_decode_length_of_byte(param) { | ||
| if (param >= 194) { | ||
| if (param >= 240) { | ||
| if (param >= 245) { | ||
| return 0; | ||
| } else { | ||
| return 4; | ||
| } | ||
| } else if (param >= 224) { | ||
| return 3; | ||
| } else { | ||
| return 2; | ||
| } | ||
| } else if (param >= 128) { | ||
| return 0; | ||
| } else { | ||
| return 1; | ||
| } | ||
| } | ||
| function utf_8_byte_length(u) { | ||
@@ -127,3 +147,3 @@ if (u < 0) { | ||
| "jscomp/stdlib/uchar.ml", | ||
| 84, | ||
| 94, | ||
| 18 | ||
@@ -149,3 +169,3 @@ ] | ||
| "jscomp/stdlib/uchar.ml", | ||
| 89, | ||
| 99, | ||
| 7 | ||
@@ -162,3 +182,3 @@ ] | ||
| "jscomp/stdlib/uchar.ml", | ||
| 92, | ||
| 102, | ||
| 18 | ||
@@ -178,3 +198,3 @@ ] | ||
| "jscomp/stdlib/uchar.ml", | ||
| 95, | ||
| 105, | ||
| 7 | ||
@@ -201,2 +221,4 @@ ] | ||
| const max_utf_8_decode_length = 4; | ||
| export { | ||
@@ -226,2 +248,4 @@ min, | ||
| utf_decode_invalid, | ||
| utf_8_decode_length_of_byte, | ||
| max_utf_8_decode_length, | ||
| utf_8_byte_length, | ||
@@ -228,0 +252,0 @@ utf_16_byte_length, |
+75
-75
@@ -245,61 +245,56 @@ // Generated by Melange | ||
| const sz = length(bucket); | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i >= sz) { | ||
| const newsz = Stdlib__Int.min((Math.imul(3, sz) / 2 | 0) + 3 | 0, Stdlib__Sys.max_array_length - 2 | 0); | ||
| if (newsz <= sz) { | ||
| throw new Caml_js_exceptions.MelangeError("Failure", { | ||
| MEL_EXN_ID: "Failure", | ||
| _1: "Weak.Make: hash bucket cannot grow more" | ||
| }); | ||
| } | ||
| const newbucket = create(newsz); | ||
| const newhashes = Caml_array.make(newsz, 0); | ||
| blit(bucket, 0, newbucket, 0, sz); | ||
| Stdlib__Array.blit(hashes, 0, newhashes, 0, sz); | ||
| Curry._3(setter, newbucket, sz, d); | ||
| Caml_array.set(newhashes, sz, h); | ||
| Caml_array.set(t.table, index, newbucket); | ||
| Caml_array.set(t.hashes, index, newhashes); | ||
| if (sz <= t.limit && newsz > t.limit) { | ||
| t.oversize = t.oversize + 1 | 0; | ||
| for (let _i$1 = 0; _i$1 <= 2; ++_i$1) { | ||
| test_shrink_bucket(t); | ||
| } | ||
| } | ||
| if (t.oversize > (t.table.length >> 1)) { | ||
| const oldlen = t.table.length; | ||
| const newlen = next_sz(oldlen); | ||
| if (newlen > oldlen) { | ||
| const newt = create$1(newlen); | ||
| const add_weak = function (ob, oh, oi) { | ||
| const setter = function (nb, ni, param) { | ||
| blit(ob, oi, nb, ni, 1); | ||
| }; | ||
| const h = Caml_array.get(oh, oi); | ||
| add_aux(newt, setter, undefined, h, get_index(newt, h)); | ||
| }; | ||
| iter_weak(add_weak, t); | ||
| t.table = newt.table; | ||
| t.hashes = newt.hashes; | ||
| t.limit = newt.limit; | ||
| t.oversize = newt.oversize; | ||
| t.rover = t.rover % newt.table.length; | ||
| return; | ||
| } | ||
| t.limit = Stdlib.max_int; | ||
| t.oversize = 0; | ||
| return; | ||
| } else { | ||
| return; | ||
| } | ||
| let i = 0; | ||
| while (i < sz && check(bucket, i)) { | ||
| i = i + 1 | 0; | ||
| }; | ||
| if (i < sz) { | ||
| Curry._3(setter, bucket, i, d); | ||
| return Caml_array.set(hashes, i, h); | ||
| } | ||
| const newsz = Stdlib__Int.min((Math.imul(3, sz) / 2 | 0) + 3 | 0, Stdlib__Sys.max_array_length - 2 | 0); | ||
| if (newsz <= sz) { | ||
| throw new Caml_js_exceptions.MelangeError("Failure", { | ||
| MEL_EXN_ID: "Failure", | ||
| _1: "Weak.Make: hash bucket cannot grow more" | ||
| }); | ||
| } | ||
| const newbucket = create(newsz); | ||
| const newhashes = Caml_array.make(newsz, 0); | ||
| blit(bucket, 0, newbucket, 0, sz); | ||
| Stdlib__Array.blit(hashes, 0, newhashes, 0, sz); | ||
| Curry._3(setter, newbucket, sz, d); | ||
| Caml_array.set(newhashes, sz, h); | ||
| Caml_array.set(t.table, index, newbucket); | ||
| Caml_array.set(t.hashes, index, newhashes); | ||
| if (sz <= t.limit && newsz > t.limit) { | ||
| t.oversize = t.oversize + 1 | 0; | ||
| for (let _i = 0; _i <= 2; ++_i) { | ||
| test_shrink_bucket(t); | ||
| } | ||
| if (check(bucket, i)) { | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| } | ||
| if (t.oversize > (t.table.length >> 1)) { | ||
| const oldlen = t.table.length; | ||
| const newlen = next_sz(oldlen); | ||
| if (newlen > oldlen) { | ||
| const newt = create$1(newlen); | ||
| const add_weak = function (ob, oh, oi) { | ||
| const setter = function (nb, ni, param) { | ||
| blit(ob, oi, nb, ni, 1); | ||
| }; | ||
| const h = Caml_array.get(oh, oi); | ||
| add_aux(newt, setter, undefined, h, get_index(newt, h)); | ||
| }; | ||
| iter_weak(add_weak, t); | ||
| t.table = newt.table; | ||
| t.hashes = newt.hashes; | ||
| t.limit = newt.limit; | ||
| t.oversize = newt.oversize; | ||
| t.rover = t.rover % newt.table.length; | ||
| return; | ||
| } | ||
| Curry._3(setter, bucket, i, d); | ||
| return Caml_array.set(hashes, i, h); | ||
| }; | ||
| t.limit = Stdlib.max_int; | ||
| t.oversize = 0; | ||
| return; | ||
| } | ||
| }; | ||
@@ -310,3 +305,3 @@ const add = function (t, d) { | ||
| }; | ||
| const find_aux = function (t, d, found, notfound) { | ||
| const find_aux = function (t, d, k_found, k_notfound) { | ||
| const h = Curry._1(H.hash, d); | ||
@@ -317,24 +312,29 @@ const index = get_index(t, h); | ||
| const sz = length(bucket); | ||
| let _i = 0; | ||
| while (true) { | ||
| const i = _i; | ||
| if (i >= sz) { | ||
| return Curry._2(notfound, h, index); | ||
| } | ||
| let found; | ||
| let i = 0; | ||
| while ((function () { | ||
| let tmp = false; | ||
| if (i < sz) { | ||
| const param = found; | ||
| tmp = param === undefined; | ||
| } | ||
| return tmp; | ||
| })()) { | ||
| if (h === Caml_array.get(hashes, i)) { | ||
| const opt = get(bucket, i); | ||
| if (opt !== undefined) { | ||
| const v = Caml_option.valFromOption(opt); | ||
| if (Curry._2(H.equal, v, d)) { | ||
| return Curry._4(found, bucket, i, opt, v); | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| if (opt !== undefined && Curry._2(H.equal, Caml_option.valFromOption(opt), d)) { | ||
| found = opt; | ||
| } else { | ||
| i = i + 1 | 0; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| } else { | ||
| i = i + 1 | 0; | ||
| } | ||
| _i = i + 1 | 0; | ||
| continue; | ||
| }; | ||
| const opt$1 = found; | ||
| if (opt$1 !== undefined) { | ||
| return Curry._4(k_found, bucket, i, opt$1, Caml_option.valFromOption(opt$1)); | ||
| } else { | ||
| return Curry._2(k_notfound, h, index); | ||
| } | ||
| }; | ||
@@ -341,0 +341,0 @@ const find_opt = function (t, d) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1048624
5.32%70
6.06%39783
5.96%20
-16.67%+ Added
- Removed
Updated