Skip to content

Commit 9d83b5d

Browse files
committed
snapshot
1 parent 985dd05 commit 9d83b5d

File tree

1 file changed

+179
-156
lines changed

1 file changed

+179
-156
lines changed

lib/es6/caml_obj.js

Lines changed: 179 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ function caml_compare(_a, _b) {
6868
while(true) {
6969
var b = _b;
7070
var a = _a;
71-
if (typeof a === "string") {
71+
var a_type = typeof a;
72+
var b_type = typeof b;
73+
if (a_type === "string") {
7274
var x = a;
7375
var y = b;
7476
if (x < y) {
@@ -81,129 +83,141 @@ function caml_compare(_a, _b) {
8183
return 1;
8284
}
8385
}
84-
else if (typeof a === "number") {
85-
return caml_int_compare(a, b);
86-
}
87-
else if (typeof a === "boolean" || typeof a === "null" || typeof a === "undefined") {
88-
var x$1 = a;
89-
var y$1 = b;
90-
if (x$1 === y$1) {
91-
return 0;
92-
}
93-
else if (x$1 < y$1) {
94-
return -1;
95-
}
96-
else {
97-
return 1;
98-
}
99-
}
100-
else if (typeof a === "function" || typeof b === "function") {
101-
throw [
102-
Caml_builtin_exceptions.invalid_argument,
103-
"compare: functional value"
104-
];
105-
}
10686
else {
107-
var tag_a = a.tag | 0;
108-
var tag_b = b.tag | 0;
109-
if (tag_a === 250) {
110-
_a = a[0];
111-
continue ;
112-
113-
}
114-
else if (tag_b === 250) {
115-
_b = b[0];
116-
continue ;
117-
118-
}
119-
else if (tag_a === 248) {
120-
return caml_int_compare(a[1], b[1]);
87+
var is_a_number = +(a_type === "number");
88+
var is_b_number = +(b_type === "number");
89+
if (is_a_number !== 0) {
90+
if (is_b_number !== 0) {
91+
return caml_int_compare(a, b);
92+
}
93+
else {
94+
return -1;
95+
}
12196
}
122-
else if (tag_a === 251) {
123-
throw [
124-
Caml_builtin_exceptions.invalid_argument,
125-
"equal: abstract value"
126-
];
97+
else if (is_b_number !== 0) {
98+
return 1;
12799
}
128-
else if (tag_a !== tag_b) {
129-
if (tag_a < tag_b) {
100+
else if (a_type === "boolean" || a_type === "null" || a_type === "undefined") {
101+
var x$1 = a;
102+
var y$1 = b;
103+
if (x$1 === y$1) {
104+
return 0;
105+
}
106+
else if (x$1 < y$1) {
130107
return -1;
131108
}
132109
else {
133110
return 1;
134111
}
135112
}
113+
else if (a_type === "function" || b_type === "function") {
114+
throw [
115+
Caml_builtin_exceptions.invalid_argument,
116+
"compare: functional value"
117+
];
118+
}
136119
else {
137-
var len_a = a.length;
138-
var len_b = b.length;
139-
if (len_a === len_b) {
140-
var a$1 = a;
141-
var b$1 = b;
142-
var _i = 0;
143-
var same_length = len_a;
144-
while(true) {
145-
var i = _i;
146-
if (i === same_length) {
147-
return 0;
148-
}
149-
else {
150-
var res = caml_compare(a$1[i], b$1[i]);
151-
if (res !== 0) {
152-
return res;
120+
var tag_a = a.tag | 0;
121+
var tag_b = b.tag | 0;
122+
if (tag_a === 250) {
123+
_a = a[0];
124+
continue ;
125+
126+
}
127+
else if (tag_b === 250) {
128+
_b = b[0];
129+
continue ;
130+
131+
}
132+
else if (tag_a === 248) {
133+
return caml_int_compare(a[1], b[1]);
134+
}
135+
else if (tag_a === 251) {
136+
throw [
137+
Caml_builtin_exceptions.invalid_argument,
138+
"equal: abstract value"
139+
];
140+
}
141+
else if (tag_a !== tag_b) {
142+
if (tag_a < tag_b) {
143+
return -1;
144+
}
145+
else {
146+
return 1;
147+
}
148+
}
149+
else {
150+
var len_a = a.length;
151+
var len_b = b.length;
152+
if (len_a === len_b) {
153+
var a$1 = a;
154+
var b$1 = b;
155+
var _i = 0;
156+
var same_length = len_a;
157+
while(true) {
158+
var i = _i;
159+
if (i === same_length) {
160+
return 0;
153161
}
154162
else {
155-
_i = i + 1 | 0;
156-
continue ;
157-
163+
var res = caml_compare(a$1[i], b$1[i]);
164+
if (res !== 0) {
165+
return res;
166+
}
167+
else {
168+
_i = i + 1 | 0;
169+
continue ;
170+
171+
}
158172
}
159-
}
160-
};
161-
}
162-
else if (len_a < len_b) {
163-
var a$2 = a;
164-
var b$2 = b;
165-
var _i$1 = 0;
166-
var short_length = len_a;
167-
while(true) {
168-
var i$1 = _i$1;
169-
if (i$1 === short_length) {
170-
return -1;
171-
}
172-
else {
173-
var res$1 = caml_compare(a$2[i$1], b$2[i$1]);
174-
if (res$1 !== 0) {
175-
return res$1;
173+
};
174+
}
175+
else if (len_a < len_b) {
176+
var a$2 = a;
177+
var b$2 = b;
178+
var _i$1 = 0;
179+
var short_length = len_a;
180+
while(true) {
181+
var i$1 = _i$1;
182+
if (i$1 === short_length) {
183+
return -1;
176184
}
177185
else {
178-
_i$1 = i$1 + 1 | 0;
179-
continue ;
180-
186+
var res$1 = caml_compare(a$2[i$1], b$2[i$1]);
187+
if (res$1 !== 0) {
188+
return res$1;
189+
}
190+
else {
191+
_i$1 = i$1 + 1 | 0;
192+
continue ;
193+
194+
}
181195
}
182-
}
183-
};
184-
}
185-
else {
186-
var a$3 = a;
187-
var b$3 = b;
188-
var _i$2 = 0;
189-
var short_length$1 = len_b;
190-
while(true) {
191-
var i$2 = _i$2;
192-
if (i$2 === short_length$1) {
193-
return 1;
194-
}
195-
else {
196-
var res$2 = caml_compare(a$3[i$2], b$3[i$2]);
197-
if (res$2 !== 0) {
198-
return res$2;
196+
};
197+
}
198+
else {
199+
var a$3 = a;
200+
var b$3 = b;
201+
var _i$2 = 0;
202+
var short_length$1 = len_b;
203+
while(true) {
204+
var i$2 = _i$2;
205+
if (i$2 === short_length$1) {
206+
return 1;
199207
}
200208
else {
201-
_i$2 = i$2 + 1 | 0;
202-
continue ;
203-
209+
var res$2 = caml_compare(a$3[i$2], b$3[i$2]);
210+
if (res$2 !== 0) {
211+
return res$2;
212+
}
213+
else {
214+
_i$2 = i$2 + 1 | 0;
215+
continue ;
216+
217+
}
204218
}
205-
}
206-
};
219+
};
220+
}
207221
}
208222
}
209223
}
@@ -217,65 +231,74 @@ function caml_equal(_a, _b) {
217231
if (a === b) {
218232
return /* true */1;
219233
}
220-
else if (typeof a === "string" || typeof a === "number" || typeof a === "boolean" || typeof a === "undefined" || typeof a === "null") {
221-
return /* false */0;
222-
}
223-
else if (typeof a === "function" || typeof b === "function") {
224-
throw [
225-
Caml_builtin_exceptions.invalid_argument,
226-
"equal: functional value"
227-
];
228-
}
229234
else {
230-
var tag_a = a.tag | 0;
231-
var tag_b = b.tag | 0;
232-
if (tag_a === 250) {
233-
_a = a[0];
234-
continue ;
235-
236-
}
237-
else if (tag_b === 250) {
238-
_b = b[0];
239-
continue ;
240-
241-
}
242-
else if (tag_a === 248) {
243-
return +(a[1] === b[1]);
244-
}
245-
else if (tag_a === 251) {
246-
throw [
247-
Caml_builtin_exceptions.invalid_argument,
248-
"equal: abstract value"
249-
];
250-
}
251-
else if (tag_a !== tag_b) {
235+
var a_type = typeof a;
236+
if (a_type === "string" || a_type === "number" || a_type === "boolean" || a_type === "undefined" || a_type === "null") {
252237
return /* false */0;
253238
}
254239
else {
255-
var len_a = a.length;
256-
var len_b = b.length;
257-
if (len_a === len_b) {
258-
var a$1 = a;
259-
var b$1 = b;
260-
var _i = 0;
261-
var same_length = len_a;
262-
while(true) {
263-
var i = _i;
264-
if (i === same_length) {
265-
return /* true */1;
266-
}
267-
else if (caml_equal(a$1[i], b$1[i])) {
268-
_i = i + 1 | 0;
269-
continue ;
270-
240+
var b_type = typeof b;
241+
if (a_type === "function" || b_type === "function") {
242+
throw [
243+
Caml_builtin_exceptions.invalid_argument,
244+
"equal: functional value"
245+
];
246+
}
247+
else if (b_type === "number" || b_type === "null" || b_type === "undefined") {
248+
return /* false */0;
249+
}
250+
else {
251+
var tag_a = a.tag | 0;
252+
var tag_b = b.tag | 0;
253+
if (tag_a === 250) {
254+
_a = a[0];
255+
continue ;
256+
257+
}
258+
else if (tag_b === 250) {
259+
_b = b[0];
260+
continue ;
261+
262+
}
263+
else if (tag_a === 248) {
264+
return +(a[1] === b[1]);
265+
}
266+
else if (tag_a === 251) {
267+
throw [
268+
Caml_builtin_exceptions.invalid_argument,
269+
"equal: abstract value"
270+
];
271+
}
272+
else if (tag_a !== tag_b) {
273+
return /* false */0;
274+
}
275+
else {
276+
var len_a = a.length;
277+
var len_b = b.length;
278+
if (len_a === len_b) {
279+
var a$1 = a;
280+
var b$1 = b;
281+
var _i = 0;
282+
var same_length = len_a;
283+
while(true) {
284+
var i = _i;
285+
if (i === same_length) {
286+
return /* true */1;
287+
}
288+
else if (caml_equal(a$1[i], b$1[i])) {
289+
_i = i + 1 | 0;
290+
continue ;
291+
292+
}
293+
else {
294+
return /* false */0;
295+
}
296+
};
271297
}
272298
else {
273299
return /* false */0;
274300
}
275-
};
276-
}
277-
else {
278-
return /* false */0;
301+
}
279302
}
280303
}
281304
}

0 commit comments

Comments
 (0)