forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaml_oo.js
47 lines (42 loc) · 1.11 KB
/
caml_oo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'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 */