-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathcamlinternalLazy.js
76 lines (68 loc) · 1.55 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
71
72
73
74
75
76
// Generated CODE, PLEASE EDIT WITH CARE
'use strict';
var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Obj = require("./obj");
var Caml_curry = require("../runtime/caml_curry");
var Undefined = {
0: "CamlinternalLazy.Undefined",
1: Caml_builtin_exceptions.get_id(),
length: 2,
tag: 248
};
function raise_undefined() {
throw Undefined;
}
function force_lazy_block(blk) {
var closure = blk[0];
blk[0] = raise_undefined;
try {
var result = Caml_curry.app1(closure, /* () */0);
blk[0] = result;
blk.tag = Obj.forward_tag;
return result;
}
catch (e){
blk[0] = function () {
throw e;
};
throw e;
}
}
function force_val_lazy_block(blk) {
var closure = blk[0];
blk[0] = raise_undefined;
var result = Caml_curry.app1(closure, /* () */0);
blk[0] = result;
blk.tag = 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);
}
}
exports.Undefined = Undefined;
exports.force_lazy_block = force_lazy_block;
exports.force_val_lazy_block = force_val_lazy_block;
exports.force = force;
exports.force_val = force_val;
/* No side effect */