UNPKG

bs-platform

Version:

ReScript compiler, OCaml standard libary by ReScript and its required runtime support

48 lines (42 loc) 1.14 kB
'use strict'; var Caml_array = require("./caml_array.js"); var Caml_exceptions = require("./caml_exceptions.js"); var caml_methods_cache = Caml_array.caml_make_vect(1000, 0); function caml_set_oo_id(b) { b[1] = Caml_exceptions.id.contents; Caml_exceptions.id.contents = Caml_exceptions.id.contents + 1 | 0; return b; } function caml_get_public_method(obj, tag, cacheid) { var meths = obj[0]; var offs = caml_methods_cache[cacheid]; if (meths[offs] === tag) { return meths[offs - 1 | 0]; } var aux = function (_i) { while(true) { var i = _i; if (i < 3) { throw { RE_EXN_ID: "Assert_failure", _1: [ "caml_oo.ml", 80, 20 ], Error: new Error() }; } if (meths[i] === tag) { caml_methods_cache[cacheid] = i; return i; } _i = i - 2 | 0; continue ; }; }; return meths[aux((meths[0] << 1) + 1 | 0) - 1 | 0]; } exports.caml_get_public_method = caml_get_public_method; exports.caml_set_oo_id = caml_set_oo_id; /* No side effect */