-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathcamlinternalLazy.js
70 lines (60 loc) · 1.34 KB
/
camlinternalLazy.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as Obj from "./obj.js";
import * as Curry from "./curry.js";
import * as Caml_obj from "./caml_obj.js";
import * as Caml_exceptions from "./caml_exceptions.js";
var Undefined = Caml_exceptions.create("CamlinternalLazy.Undefined");
function raise_undefined(param) {
throw Undefined;
}
function force_lazy_block(blk) {
var closure = blk[0];
blk[0] = raise_undefined;
try {
var result = Curry._1(closure, undefined);
blk[0] = result;
Caml_obj.caml_obj_set_tag(blk, Obj.forward_tag);
return result;
}
catch (e){
blk[0] = (function (param) {
throw e;
});
throw e;
}
}
function force_val_lazy_block(blk) {
var closure = blk[0];
blk[0] = raise_undefined;
var result = Curry._1(closure, undefined);
blk[0] = result;
Caml_obj.caml_obj_set_tag(blk, Obj.forward_tag);
return result;
}
function force(lzv) {
var t = lzv.tag | 0;
if (t === Obj.forward_tag) {
return lzv[0];
} else if (t !== Obj.lazy_tag) {
return lzv;
} else {
return force_lazy_block(lzv);
}
}
function force_val(lzv) {
var t = lzv.tag | 0;
if (t === Obj.forward_tag) {
return lzv[0];
} else if (t !== Obj.lazy_tag) {
return lzv;
} else {
return force_val_lazy_block(lzv);
}
}
export {
Undefined ,
force_lazy_block ,
force_val_lazy_block ,
force ,
force_val ,
}
/* No side effect */