forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.1.js
226 lines (226 loc) · 10.8 KB
/
bench.1.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// Generated by js_of_ocaml 2.8.1
(function(C){"use strict";var
$="Sys_error",O=".",N="+",ai="Invalid_argument",y=1024,ah="End_of_file",M="e",n=" ",ag="Failure",_="Undefined_recursive_module",m="-",af="Stack_overflow",o=128,d="",L=" : file already exists",g="0",a=248,ae="Not_found",Y="Assert_failure",Z="/",ac="Sys_blocked_io",ad="fd ",X="Out_of_memory",ab="Match_failure",aa="Division_by_zero";function
a0(d,e,c){var
b=new
Array(c);for(var
a=0;a<c;a++)b[a]=d[e+a];return b}function
R(b,c,a){var
e=String.fromCharCode;if(c==0&&a<=4096&&a==b.length)return e.apply(null,b);var
f=d;for(;0<a;c+=y,a-=y)f+=e.apply(null,a0(b,c,Math.min(a,y)));return f}function
aj(b){if(C.Uint8Array)var
c=new(C.Uint8Array)(b.l);else
var
c=new
Array(b.l);var
e=b.c,d=e.length,a=0;for(;a<d;a++)c[a]=e.charCodeAt(a);for(d=b.l;a<d;a++)c[a]=0;b.c=c;b.t=4;return c}function
s(d,e,a,f,c){if(c==0)return 0;if(f==0&&(c>=a.l||a.t==2&&c>=a.c.length)){a.c=d.t==4?R(d.c,e,c):e==0&&d.c.length==c?d.c:d.c.substr(e,c);a.t=a.c.length==a.l?0:2}else
if(a.t==2&&f==a.c.length){a.c+=d.t==4?R(d.c,e,c):e==0&&d.c.length==c?d.c:d.c.substr(e,c);a.t=a.c.length==a.l?0:2}else{if(a.t!=4)aj(a);var
g=d.c,h=a.c;if(d.t==4)for(var
b=0;b<c;b++)h[f+b]=g[e+b];else{var
i=Math.min(c,g.length-e);for(var
b=0;b<i;b++)h[f+b]=g.charCodeAt(e+b);for(;b<c;b++)h[f+b]=0}}return 0}function
aP(b,a){if(a.repeat)return a.repeat(b);var
c=d,e=0;if(b==0)return c;for(;;){if(b&1)c+=a;b>>=1;if(b==0)return c;a+=a;e++;if(e==9)a.slice(0,1)}}function
ak(a){if(a.t==2)a.c+=aP(a.l-a.c.length,"\0");else
a.c=R(a.c,0,a.c.length);a.t=0}function
aG(a){if(a.length<24){for(var
b=0;b<a.length;b++)if(a.charCodeAt(b)>127)return false;return true}else
return!/[^\x00-\x7f]/.test(a)}function
aX(f){for(var
k=d,c=d,h,g,i,a,b=0,j=f.length;b<j;b++){g=f.charCodeAt(b);if(g<o){for(var
e=b+1;e<j&&(g=f.charCodeAt(e))<o;e++);if(e-b>512){c.substr(0,1);k+=c;c=d;k+=f.slice(b,e)}else
c+=f.slice(b,e);if(e==j)break;b=e}a=1;if(++b<j&&((i=f.charCodeAt(b))&-64)==o){h=i+(g<<6);if(g<224){a=h-12416;if(a<o)a=1}else{a=2;if(++b<j&&((i=f.charCodeAt(b))&-64)==o){h=i+(h<<6);if(g<240){a=h-925824;if(a<2048||a>=55295&&a<57344)a=2}else{a=3;if(++b<j&&((i=f.charCodeAt(b))&-64)==o&&g<245){a=i-63447168+(h<<6);if(a<65536||a>1114111)a=3}}}}}if(a<4){b-=a;c+="\ufffd"}else
if(a>65535)c+=String.fromCharCode(55232+(a>>10),56320+(a&1023));else
c+=String.fromCharCode(a);if(c.length>y){c.substr(0,1);k+=c;c=d}}return k+c}function
aW(a){switch(a.t){case
9:return a.c;default:ak(a);case
0:if(aG(a.c)){a.t=9;return a.c}a.t=8;case
8:return aX(a.c)}}function
k(c,a,b){this.t=c;this.c=a;this.l=b}k.prototype.toString=function(){return aW(this)};function
aM(b,a){throw[0,b,a]}function
b(a){return new
k(0,a,a.length)}function
ap(c,a){aM(c,b(a))}var
c=[0];function
z(a){ap(c.Invalid_argument,a)}function
i(a){if(a<0)z("String.create");return new
k(a?2:9,d,a)}function
aB(a){if((a.t&6)!=0)ak(a);return a.c}function
aL(d){d=aB(d);var
e=d.length;if(e>31)z("format_int: format too long");var
a={justify:N,signstyle:m,filler:n,alternate:false,base:0,signedconv:false,width:0,uppercase:false,sign:1,prec:-1,conv:"f"};for(var
c=0;c<e;c++){var
b=d.charAt(c);switch(b){case"-":a.justify=m;break;case"+":case" ":a.signstyle=b;break;case"0":a.filler=g;break;case"#":a.alternate=true;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":a.width=0;while(b=d.charCodeAt(c)-48,b>=0&&b<=9){a.width=a.width*10+b;c++}c--;break;case".":a.prec=0;c++;while(b=d.charCodeAt(c)-48,b>=0&&b<=9){a.prec=a.prec*10+b;c++}c--;case"d":case"i":a.signedconv=true;case"u":a.base=10;break;case"x":a.base=16;break;case"X":a.base=16;a.uppercase=true;break;case"o":a.base=8;break;case"e":case"f":case"g":a.signedconv=true;a.conv=b;break;case"E":case"F":case"G":a.signedconv=true;a.uppercase=true;a.conv=b.toLowerCase();break}}return a}function
aD(a,h){if(a.uppercase)h=h.toUpperCase();var
f=h.length;if(a.signedconv&&(a.sign<0||a.signstyle!=m))f++;if(a.alternate){if(a.base==8)f+=1;if(a.base==16)f+=2}var
c=d;if(a.justify==N&&a.filler==n)for(var
e=f;e<a.width;e++)c+=n;if(a.signedconv)if(a.sign<0)c+=m;else
if(a.signstyle!=m)c+=a.signstyle;if(a.alternate&&a.base==8)c+=g;if(a.alternate&&a.base==16)c+="0x";if(a.justify==N&&a.filler==g)for(var
e=f;e<a.width;e++)c+=g;c+=h;if(a.justify==m)for(var
e=f;e<a.width;e++)c+=n;return b(c)}function
aE(j,c){var
a,e=aL(j),d=e.prec<0?6:e.prec;if(c<0||c==0&&1/c==-Infinity){e.sign=-1;c=-c}if(isNaN(c)){a="nan";e.filler=n}else
if(!isFinite(c)){a="inf";e.filler=n}else
switch(e.conv){case"e":var
a=c.toExponential(d),b=a.length;if(a.charAt(b-3)==M)a=a.slice(0,b-1)+g+a.slice(b-1);break;case"f":a=c.toFixed(d);break;case"g":d=d?d:1;a=c.toExponential(d-1);var
i=a.indexOf(M),h=+a.slice(i+1);if(h<-4||c>=1e+21||c.toFixed(0).length>d){var
b=i-1;while(a.charAt(b)==g)b--;if(a.charAt(b)==O)b--;a=a.slice(0,b+1)+a.slice(i);b=a.length;if(a.charAt(b-3)==M)a=a.slice(0,b-1)+g+a.slice(b-1);break}else{var
f=d;if(h<0){f-=h+1;a=c.toFixed(f)}else
while(a=c.toFixed(f),a.length>d+1)f--;if(f){var
b=a.length-1;while(a.charAt(b)==g)b--;if(a.charAt(b)==O)b--;a=a.slice(0,b+1)}}break}return aD(e,a)}function
al(a,d){var
a=a+1|0,b=new
Array(a);b[0]=0;for(var
c=1;c<a;c++)b[c]=d;return b}function
f(a){ap(c.Sys_error,a)}function
Q(a){if(!a.opened)f("Cannot flush a closed channel");if(a.buffer==d)return 0;if(a.output)switch(a.output.length){case
2:a.output(a,a.buffer);break;default:a.output(a.buffer)}a.buffer=d;return 0}var
aq=0;function
a1(){return new
Date().getTime()/1e3}function
S(){return Math.floor(a1())}function
h(b){this.data=b;this.inode=aq++;var
a=S();this.atime=a;this.mtime=a;this.ctime=a}h.prototype={truncate:function(){this.data=i(0);this.modified()},modified:function(){var
a=S();this.atime=a;this.mtime=a}};function
l(a){return a.l}function
ao(a){a=a
instanceof
k?a.toString():a;f(a+": No such file or directory")}var
aC=Z;function
A(a){a=a
instanceof
k?a.toString():a;if(a.charCodeAt(0)!=47)a=aC+a;var
e=a.split(Z),b=[];for(var
c=0;c<e.length;c++)switch(e[c]){case"..":if(b.length>1)b.pop();break;case".":break;case"":if(b.length==0)b.push(d);break;default:b.push(e[c]);break}b.orig=a;return b}function
j(){this.content={};this.inode=aq++;var
a=S();this.atime=a;this.mtime=a;this.ctime=a}j.prototype={exists:function(a){return this.content[a]?1:0},mk:function(b,a){this.content[b]=a},get:function(a){return this.content[a]},list:function(){var
a=[];for(var
b
in
this.content)a.push(b);return a},remove:function(a){delete
this.content[a]}};var
B=new
j();B.mk(d,new
j());function
P(c){var
a=B;for(var
b=0;b<c.length;b++){if(!(a.exists&&a.exists(c[b])))ao(c.orig);a=a.get(c[b])}return a}function
aV(b){var
c=A(b),a=P(c);return a
instanceof
j?1:0}function
aS(a){return new
k(4,a,a.length)}function
a2(a){if(a.t!=4)aj(a);return a.c}function
aF(l,c){var
e=A(l),a=B;for(var
g=0;g<e.length-1;g++){var
d=e[g];if(!a.exists(d))a.mk(d,new
j());a=a.get(d);if(!(a
instanceof
j))f(e.orig+L)}var
d=e[e.length-1];if(a.exists(d))f(e.orig+L);if(c
instanceof
j)a.mk(d,c);else
if(c
instanceof
h)a.mk(d,c);else
if(c
instanceof
k)a.mk(d,new
h(c));else
if(c
instanceof
Array)a.mk(d,new
h(aS(c)));else
if(c.toString){var
i=b(c.toString());a.mk(d,new
h(i))}else
z("caml_fs_register");return 0}function
aU(f){var
a=B,c=A(f),d,e;for(var
b=0;b<c.length;b++){if(a.auto){d=a.auto;e=b}if(!(a.exists&&a.exists(c[b])))return d?d(c,e):0;a=a.get(c[b])}return 1}function
u(d,e,a){if(c.fds===undefined)c.fds=new
Array();a=a?a:{};var
b={};b.file=e;b.offset=a.append?l(e.data):0;b.flags=a;c.fds[d]=b;c.fd_last_idx=d;return d}function
a3(b,e,k){var
a={};while(e){switch(e[1]){case
0:a.rdonly=1;break;case
1:a.wronly=1;break;case
2:a.append=1;break;case
3:a.create=1;break;case
4:a.truncate=1;break;case
5:a.excl=1;break;case
6:a.binary=1;break;case
7:a.text=1;break;case
8:a.nonblock=1;break}e=e[2]}var
g=b.toString(),j=A(b);if(a.rdonly&&a.wronly)f(g+" : flags Open_rdonly and Open_wronly are not compatible");if(a.text&&a.binary)f(g+" : flags Open_text and Open_binary are not compatible");if(aU(b)){if(aV(b))f(g+" : is a directory");if(a.create&&a.excl)f(g+L);var
h=c.fd_last_idx?c.fd_last_idx:0,d=P(j);if(a.truncate)d.truncate();return u(h+1,d,a)}else
if(a.create){var
h=c.fd_last_idx?c.fd_last_idx:0;aF(b,i(0));var
d=P(j);return u(h+1,d,a)}else
ao(b)}u(0,new
h(i(0)));u(1,new
h(i(0)));u(2,new
h(i(0)));function
aH(b){var
a=c.fds[b];if(a.flags.wronly)f(ad+b+" is writeonly");return{file:a.file,offset:a.offset,fd:b,opened:true,refill:null}}function
aY(a){var
b=C;if(b.process&&b.process.stdout&&b.process.stdout.write)b.process.stderr.write(a);else{if(a.charCodeAt(a.length-1)==10)a=a.substr(0,a.length-1);var
c=b.console;c&&c.error&&c.error(a)}}function
aZ(a){var
b=C;if(b.process&&b.process.stdout&&b.process.stdout.write)b.process.stdout.write(a);else{if(a.charCodeAt(a.length-1)==10)a=a.substr(0,a.length-1);var
c=b.console;c&&c.log&&c.log(a)}}var
t=new
Array();function
aO(a,h){var
g=b(h),c=l(g),f=l(a.file.data),e=a.offset;if(e+c>=f){var
d=i(e+c);s(a.file.data,0,d,0,f);s(g,0,d,e,c);a.file.data=d}a.offset+=c;a.file.modified();return 0}function
am(a){var
b;switch(a){case
1:b=aZ;break;case
2:b=aY;break;default:b=aO}var
g=c.fds[a];if(g.flags.rdonly)f(ad+a+" is readonly");var
e={file:g.file,offset:g.offset,fd:a,opened:true,buffer:d,output:b};t[e.fd]=e;return e}function
aI(){var
b=0;for(var
a=0;a<t.length;a++)if(t[a]&&t[a].opened)b=[0,t[a],b];return b}function
an(a,d,h,g){if(!a.opened)f("Cannot output to a closed channel");var
c;if(h==0&&l(d)==g)c=d;else{c=i(g);s(d,h,c,0,g)}var
b=c.toString(),e=b.lastIndexOf("\n");if(e<0)a.buffer+=b;else{a.buffer+=b.substr(0,e+1);Q(a);a.buffer+=b.substr(e+1)}return 0}function
aJ(c,a){var
d=b(String.fromCharCode(a));an(c,d,0,1);return 0}function
e(d,b,a){c[d+1]=b;if(a)c[a]=b}var
aK=0;function
aN(a){a[2]=aK++;return a}function
aQ(){z("index out of bounds")}function
aT(a,b){switch(a.t&6){default:if(b>=a.c.length)return 0;case
0:return a.c.charCodeAt(b);case
4:return a.c[b]}}function
aR(b,a){if(a>>>0>=b.l)aQ();return aT(b,a)}e(11,[a,b(_),-12],_);e(10,[a,b(Y),-11],Y);e(9,[a,b(ac),-10],ac);e(8,[a,b(af),-9],af);e(7,[a,b(ab),-8],ab);e(6,[a,b(ae),-7],ae);e(5,[a,b(aa),-6],aa);e(4,[a,b(ah),-5],ah);e(3,[a,b(ai),-4],ai);e(2,[a,b(ag),-3],ag);e(1,[a,b($),-2],$);e(0,[a,b(X),-1],X);aN([a,b("Pervasives.Exit"),0]);aH(0);var
G=am(1);am(2);var
w=al(3e6,0),r=1,at=b("%.12g"),as=b(O);for(;;){w[r+1]=r;var
ax=r+1|0;if(2999999!==r){var
r=ax;continue}var
V=function(a){return a+a-1},H=w.length-1;if(0===H)var
J=[0];else{var
T=al(H,V(w[1])),U=H-1|0,av=1;if(!(U<1)){var
q=av;for(;;){T[q+1]=V(w[q+1]);var
aw=q+1|0;if(U!==q){var
q=aw;continue}break}}var
J=T}var
I=[0,0],W=J.length-1-1|0,ay=0;if(!(W<0)){var
x=ay;for(;;){I[1]=I[1]+J[x+1];var
az=x+1|0;if(W!==x){var
x=az;continue}break}}var
p=aE(at,I[1]),v=0,ar=l(p);for(;;){if(ar<=v){var
D=l(p),E=i(D+1|0);s(p,0,E,0,D);s(as,0,E,D,1);var
K=E}else{var
F=aR(p,v),aA=48<=F?58<=F?0:1:45===F?1:0;if(aA){var
v=v+1|0;continue}var
K=p}an(G,K,0,l(K));aJ(G,10);Q(G);var
au=function(b){var
a=b;for(;;){if(a){var
c=a[2],d=a[1];try{Q(d)}catch(a){}var
a=c;continue}return 0}};au(aI(0));return}}}(function(){return this}()));