From 524650e3e8f3143a4e99394055b3aca8d08aac95 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 20 Mar 2023 14:42:19 +0100 Subject: [PATCH 01/13] Emit tags as strings. --- jscomp/test/adt_optimize_test.js | 14 +- jscomp/test/ast_abstract_test.js | 153 + jscomp/test/ast_js_mapper_poly_test.js | 272 + jscomp/test/ast_mapper_defensive_test.js | 96 + jscomp/test/bal_set_mini.js | 37 +- jscomp/test/bdd.js | 21 +- jscomp/test/defunctor_make_test.js | 28 +- jscomp/test/demo_int_map.js | 30 +- jscomp/test/demo_page.js | 5 +- jscomp/test/flexible_array_test.js | 41 +- jscomp/test/flow_parser_reg_test.js | 6406 +++++++++--------- jscomp/test/fun_pattern_match.js | 8 +- jscomp/test/gpr_1658_test.js | 2 +- jscomp/test/gpr_3209_test.js | 2 +- jscomp/test/gpr_3609_test.js | 2 +- jscomp/test/gpr_4519_test.js | 8 +- jscomp/test/gpr_4900_test.js | 2 +- jscomp/test/gpr_4924_test.js | 14 +- jscomp/test/gpr_5280_optimize_test.js | 5 +- jscomp/test/inline_map2_test.js | 354 +- jscomp/test/inline_map_demo.js | 30 +- jscomp/test/inline_map_test.js | 30 +- jscomp/test/inline_record_test.js | 19 +- jscomp/test/int_map.js | 156 +- jscomp/test/js_json_test.js | 42 +- jscomp/test/large_record_duplication_test.js | 9 +- jscomp/test/lexer_test.js | 219 + jscomp/test/map_find_test.js | 60 +- jscomp/test/map_test.js | 77 +- jscomp/test/mario_game.js | 263 +- jscomp/test/mutual_non_recursive_type.js | 3 +- jscomp/test/ocaml_re_test.js | 1061 ++- jscomp/test/offset.js | 165 +- jscomp/test/option_repr_test.js | 2 +- jscomp/test/pq_test.js | 25 +- jscomp/test/rbset.js | 342 +- jscomp/test/rec_module_test.js | 165 +- jscomp/test/record_extension_test.js | 6 +- jscomp/test/recursive_records_test.js | 7 +- jscomp/test/set_gen.js | 124 +- jscomp/test/string_set.js | 35 +- jscomp/test/test_demo.js | 8 +- jscomp/test/test_fib.js | 10 +- jscomp/test/test_for_map.js | 156 +- jscomp/test/test_int_map_find.js | 28 +- jscomp/test/test_set.js | 137 +- jscomp/test/test_string_map.js | 30 +- jscomp/test/test_switch.js | 2 +- jscomp/test/test_trywith.js | 2 +- jscomp/test/ticker.js | 185 +- jscomp/test/topsort_test.js | 165 +- jscomp/test/typeof_test.js | 2 +- jscomp/test/utf8_decode_test.js | 8 +- jscomp/test/variant.js | 6 +- jscomp/test/variantsMatching.js | 12 +- lib/es6/caml_module.js | 6 +- lib/es6/hashtbl.js | 129 +- lib/es6/map.js | 156 +- lib/es6/mapLabels.js | 156 +- lib/es6/moreLabels.js | 321 +- lib/es6/queue.js | 24 +- lib/es6/set.js | 165 +- lib/es6/setLabels.js | 165 +- lib/es6/stream.js | 12 +- lib/js/caml_module.js | 6 +- lib/js/hashtbl.js | 129 +- lib/js/map.js | 156 +- lib/js/mapLabels.js | 156 +- lib/js/moreLabels.js | 321 +- lib/js/queue.js | 24 +- lib/js/set.js | 165 +- lib/js/setLabels.js | 165 +- lib/js/stream.js | 12 +- 73 files changed, 6831 insertions(+), 6528 deletions(-) create mode 100644 jscomp/test/ast_js_mapper_poly_test.js create mode 100644 jscomp/test/ast_mapper_defensive_test.js create mode 100644 jscomp/test/lexer_test.js diff --git a/jscomp/test/adt_optimize_test.js b/jscomp/test/adt_optimize_test.js index 3e2ef4f589..f42842fbb5 100644 --- a/jscomp/test/adt_optimize_test.js +++ b/jscomp/test/adt_optimize_test.js @@ -61,7 +61,7 @@ function f4(param) { } function f5(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "A" : return 1; @@ -84,7 +84,7 @@ function f5(param) { } function f6(param) { - if (typeof param === "object") { + if (typeof param !== "string") { return 1; } switch (param) { @@ -98,7 +98,7 @@ function f6(param) { } function f7(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "A" : return 1; @@ -122,7 +122,7 @@ function f7(param) { } function f8(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "T60" : case "T61" : @@ -142,7 +142,7 @@ function f8(param) { } function f9(param) { - if (typeof param !== "object") { + if (typeof param === "string") { if (param === "T63") { return 3; } else { @@ -161,7 +161,7 @@ function f9(param) { } function f10(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "T60" : return 0; @@ -187,7 +187,7 @@ function f10(param) { } function f11(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return 2; } if (x.TAG === "D") { diff --git a/jscomp/test/ast_abstract_test.js b/jscomp/test/ast_abstract_test.js index e3410cbc31..a2ec672687 100644 --- a/jscomp/test/ast_abstract_test.js +++ b/jscomp/test/ast_abstract_test.js @@ -76,12 +76,144 @@ idx("b"); idx("c"); +var jsMapperConstantArray = [ + 0, + 3, + 4 +]; + +function aToJs(param) { + return jsMapperConstantArray[param]; +} + +function aFromJs(param) { + return Js_mapperRt.fromIntAssert(3, jsMapperConstantArray, param); +} + +function id(x) { + eq("File \"ast_abstract_test.ml\", line 49, characters 8-15", aFromJs(aToJs(x)), x); +} + +var a0 = aToJs("A"); + +var a1 = aToJs("B"); + +id("A"); + +id("B"); + +id("C"); + +function bToJs(param) { + return param + 0 | 0; +} + +function bFromJs(param) { + if (!(param <= 3 && 0 <= param)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 1, + -1 + ], + Error: new Error() + }; + } + return param - 0 | 0; +} + +function idb(v) { + eq("File \"ast_abstract_test.ml\", line 71, characters 5-12", bFromJs(v + 0 | 0), v); +} + +idb("D0"); + +idb("D1"); + +idb("D2"); + +idb("D3"); + +function cToJs(param) { + return param + 3 | 0; +} + +function cFromJs(param) { + if (!(param <= 6 && 3 <= param)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 1, + -1 + ], + Error: new Error() + }; + } + return param - 3 | 0; +} + +function idc(v) { + eq("File \"ast_abstract_test.ml\", line 83, characters 15-22", cFromJs(v + 3 | 0), v); +} + +idc("D0"); + +idc("D1"); + +idc("D2"); + +idc("D3"); + +function hToJs(param) { + return param + 0 | 0; +} + +function hFromJs(param) { + if (!(param <= 1 && 0 <= param)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 1, + -1 + ], + Error: new Error() + }; + } + return param - 0 | 0; +} + +function zToJs(param) { + return param + 0 | 0; +} + +function zFromJs(param) { + if (param <= 2 && 0 <= param) { + return param - 0 | 0; + } + +} + Mt.from_pair_suites("Ast_abstract_test", suites.contents); var x0 = "a"; var x1 = "b"; +var b0 = 0; + +var b1 = 1; + +var c0 = 3; + +var jsMapperEraseType = "JsMapperEraseType"; + +var b = "B"; + +var zXx = "ZXx"; + exports.suites = suites; exports.test_id = test_id; exports.eq = eq; @@ -94,4 +226,25 @@ exports.xFromJs = xFromJs; exports.idx = idx; exports.x0 = x0; exports.x1 = x1; +exports.aToJs = aToJs; +exports.aFromJs = aFromJs; +exports.id = id; +exports.a0 = a0; +exports.a1 = a1; +exports.bToJs = bToJs; +exports.bFromJs = bFromJs; +exports.b0 = b0; +exports.b1 = b1; +exports.idb = idb; +exports.cToJs = cToJs; +exports.cFromJs = cFromJs; +exports.c0 = c0; +exports.idc = idc; +exports.jsMapperEraseType = jsMapperEraseType; +exports.b = b; +exports.hToJs = hToJs; +exports.hFromJs = hFromJs; +exports.zXx = zXx; +exports.zToJs = zToJs; +exports.zFromJs = zFromJs; /* Not a pure module */ diff --git a/jscomp/test/ast_js_mapper_poly_test.js b/jscomp/test/ast_js_mapper_poly_test.js new file mode 100644 index 0000000000..62c5f76346 --- /dev/null +++ b/jscomp/test/ast_js_mapper_poly_test.js @@ -0,0 +1,272 @@ +'use strict'; + +var Mt = require("./mt.js"); +var $$Array = require("../../lib/js/array.js"); +var Js_mapperRt = require("../../lib/js/js_mapperRt.js"); + +var suites = { + contents: /* [] */0 +}; + +var test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + String(test_id.contents)), + (function (param) { + return { + TAG: "Eq", + _0: x, + _1: y + }; + }) + ], + tl: suites.contents + }; +} + +var _map = {"D":"D","C":"C","f":"x"}; + +var _revMap = {"D":"D","C":"C","x":"f"}; + +function uToJs(param) { + return _map[param]; +} + +function uFromJs(param) { + return _revMap[param]; +} + +function eqU(x, y) { + return x === y; +} + +function eqUOpt(x, y) { + if (x !== undefined) { + if (y !== undefined) { + return x === y; + } else { + return false; + } + } else { + return y === undefined; + } +} + +eq("File \"ast_js_mapper_poly_test.ml\", line 25, characters 5-12", eqUOpt(uFromJs("x"), "f"), true); + +eq("File \"ast_js_mapper_poly_test.ml\", line 26, characters 5-12", eqUOpt(uFromJs("D"), "D"), true); + +eq("File \"ast_js_mapper_poly_test.ml\", line 27, characters 5-12", eqUOpt(uFromJs("C"), "C"), true); + +eq("File \"ast_js_mapper_poly_test.ml\", line 28, characters 5-12", eqUOpt(uFromJs("f"), undefined), true); + +eq("File \"ast_js_mapper_poly_test.ml\", line 29, characters 5-12", $$Array.map(uToJs, [ + "D", + "C", + "f" + ]), [ + "D", + "C", + "x" + ]); + +var jsMapperConstantArray = [ + 0, + 3, + 4, + 5 +]; + +function vToJs(param) { + return jsMapperConstantArray[param]; +} + +function vFromJs(param) { + return Js_mapperRt.fromInt(4, jsMapperConstantArray, param); +} + +function eqV(x, y) { + return x === y; +} + +function eqVOpt(x, y) { + if (x !== undefined) { + if (y !== undefined) { + return x === y; + } else { + return false; + } + } else { + return y === undefined; + } +} + +function s(param) { + switch (param) { + case "A0" : + return "A0"; + case "A1" : + return "A1"; + case "A2" : + return "A2"; + case "A3" : + return "A3"; + + } +} + +eq("File \"ast_js_mapper_poly_test.ml\", line 54, characters 5-12", $$Array.map(vToJs, [ + "A0", + "A1", + "A2", + "A3" + ]), [ + 0, + 3, + 4, + 5 + ]); + +eq("File \"ast_js_mapper_poly_test.ml\", line 55, characters 5-12", $$Array.map(vFromJs, [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ]), [ + "A0", + undefined, + undefined, + "A1", + "A2", + "A3", + undefined + ]); + +function v1ToJs(param) { + return param + 0 | 0; +} + +function v1FromJs(param) { + if (param <= 5 && 0 <= param) { + return param - 0 | 0; + } + +} + +eq("File \"ast_js_mapper_poly_test.ml\", line 68, characters 5-12", $$Array.map(v1ToJs, [ + "B0", + "B1", + "B2", + "B3", + "B4", + "B5" + ]), [ + 0, + 1, + 2, + 3, + 4, + 5 + ]); + +eq("File \"ast_js_mapper_poly_test.ml\", line 69, characters 5-12", $$Array.map(v1FromJs, [ + -1, + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ]), [ + undefined, + "B0", + "B1", + "B2", + "B3", + "B4", + "B5", + undefined + ]); + +function v2ToJs(param) { + return param + 2 | 0; +} + +function v2FromJs(param) { + if (param <= 7 && 2 <= param) { + return param - 2 | 0; + } + +} + +eq("File \"ast_js_mapper_poly_test.ml\", line 86, characters 5-12", $$Array.map(v2ToJs, [ + "C0", + "C1", + "C2", + "C3", + "C4", + "C5" + ]), [ + 2, + 3, + 4, + 5, + 6, + 7 + ]); + +eq("File \"ast_js_mapper_poly_test.ml\", line 89, characters 5-12", $$Array.map(v2FromJs, [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ]), $$Array.append($$Array.append([ + undefined, + undefined + ], $$Array.map((function (x) { + return x; + }), [ + "C0", + "C1", + "C2", + "C3", + "C4", + "C5" + ])), [undefined])); + +Mt.from_pair_suites("Ast_js_mapper_poly_test", suites.contents); + +var $plus$great = $$Array.append; + +exports.suites = suites; +exports.test_id = test_id; +exports.eq = eq; +exports.uToJs = uToJs; +exports.uFromJs = uFromJs; +exports.eqU = eqU; +exports.eqUOpt = eqUOpt; +exports.vToJs = vToJs; +exports.vFromJs = vFromJs; +exports.eqV = eqV; +exports.eqVOpt = eqVOpt; +exports.s = s; +exports.v1ToJs = v1ToJs; +exports.v1FromJs = v1FromJs; +exports.v2ToJs = v2ToJs; +exports.v2FromJs = v2FromJs; +exports.$plus$great = $plus$great; +/* Not a pure module */ diff --git a/jscomp/test/ast_mapper_defensive_test.js b/jscomp/test/ast_mapper_defensive_test.js new file mode 100644 index 0000000000..c742f9bf32 --- /dev/null +++ b/jscomp/test/ast_mapper_defensive_test.js @@ -0,0 +1,96 @@ +'use strict'; + +var Mt = require("./mt.js"); +var Js_mapperRt = require("../../lib/js/js_mapperRt.js"); + +var suites = { + contents: /* [] */0 +}; + +var test_id = { + contents: 0 +}; + +function $$throw(loc, x) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + String(test_id.contents)), + (function (param) { + return { + TAG: "ThrowAny", + _0: x + }; + }) + ], + tl: suites.contents + }; +} + +function aToJs(param) { + return param + 0 | 0; +} + +function aFromJs(param) { + if (!(param <= 2 && 0 <= param)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 1, + -1 + ], + Error: new Error() + }; + } + return param - 0 | 0; +} + +var jsMapperConstantArray = [ + 0, + 3, + 4 +]; + +function bToJs(param) { + return jsMapperConstantArray[param]; +} + +function bFromJs(param) { + return Js_mapperRt.fromIntAssert(3, jsMapperConstantArray, param); +} + +var _map = {"c0":"c0","c1":"c1","c2":"c2"}; + +function cToJs(param) { + return param; +} + +function cFromJs(param) { + return Js_mapperRt.raiseWhenNotFound(_map[param]); +} + +$$throw("File \"ast_mapper_defensive_test.ml\", line 28, characters 16-23", (function (param) { + aFromJs(3); + })); + +$$throw("File \"ast_mapper_defensive_test.ml\", line 29, characters 15-22", (function (param) { + bFromJs(2); + })); + +$$throw("File \"ast_mapper_defensive_test.ml\", line 30, characters 15-22", (function (param) { + cFromJs(33); + })); + +Mt.from_pair_suites("Ast_mapper_defensive_test", suites.contents); + +exports.suites = suites; +exports.test_id = test_id; +exports.$$throw = $$throw; +exports.aToJs = aToJs; +exports.aFromJs = aFromJs; +exports.bToJs = bToJs; +exports.bFromJs = bFromJs; +exports.cToJs = cToJs; +exports.cFromJs = cFromJs; +/* Not a pure module */ diff --git a/jscomp/test/bal_set_mini.js b/jscomp/test/bal_set_mini.js index c54c314a8f..d329e9f154 100644 --- a/jscomp/test/bal_set_mini.js +++ b/jscomp/test/bal_set_mini.js @@ -2,7 +2,7 @@ function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._3; @@ -12,8 +12,7 @@ function height(param) { function create(l, v, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: v, _2: r, @@ -25,7 +24,7 @@ function bal(l, v, r) { var hl = height(l); var hr = height(r); if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { return "Empty"; } var lr = l._2; @@ -33,22 +32,21 @@ function bal(l, v, r) { var ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); - } else if (typeof lr !== "object") { + } else if (typeof lr === "string") { return "Empty"; } else { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: v, _2: r, _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { return "Empty"; } var rr = r._2; @@ -56,7 +54,7 @@ function bal(l, v, r) { var rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); - } else if (typeof rl !== "object") { + } else if (typeof rl === "string") { return "Empty"; } else { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); @@ -74,9 +72,8 @@ function compare_int(x, y) { } function add(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: "Empty", @@ -100,11 +97,11 @@ function min_elt(_def, _param) { while(true) { var param = _param; var def = _def; - if (typeof param !== "object") { + if (typeof param === "string") { return def; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._1; } _param = l; @@ -114,7 +111,7 @@ function min_elt(_def, _param) { } function remove_min_elt(l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; } else { return bal(remove_min_elt(l._0, l._1, l._2), v, r); @@ -122,10 +119,10 @@ function remove_min_elt(l, v, r) { } function internal_merge(l, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; } - if (typeof r !== "object") { + if (typeof r === "string") { return l; } var rv = r._1; @@ -133,7 +130,7 @@ function internal_merge(l, r) { } function remove(x, tree) { - if (typeof tree !== "object") { + if (typeof tree === "string") { return "Empty"; } var r = tree._2; @@ -152,7 +149,7 @@ function remove(x, tree) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = compare_int(x, param._1); @@ -183,7 +180,7 @@ for(var i$2 = 0; i$2 <= 100000; ++i$2){ var match = v; -if (typeof match === "object") { +if (typeof match !== "string") { console.log("impossible"); } diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index c82e6baef6..aaef425f01 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -5,7 +5,7 @@ var Caml_array = require("../../lib/js/caml_array.js"); function $$eval(_bdd, vars) { while(true) { var bdd = _bdd; - if (typeof bdd !== "object") { + if (typeof bdd === "string") { if (bdd === "One") { return true; } else { @@ -22,7 +22,7 @@ function $$eval(_bdd, vars) { } function getId(bdd) { - if (typeof bdd !== "object") { + if (typeof bdd === "string") { if (bdd === "One") { return 1; } else { @@ -64,7 +64,7 @@ function resize(newSize) { return ; } var n = bucket.hd; - if (typeof n !== "object") { + if (typeof n === "string") { if (n === "One") { throw { RE_EXN_ID: "Assert_failure", @@ -140,7 +140,7 @@ function mkNode(low, v, high) { var b = _b; if (b) { var n = b.hd; - if (typeof n !== "object") { + if (typeof n === "string") { if (n === "One") { throw { RE_EXN_ID: "Assert_failure", @@ -170,8 +170,7 @@ function mkNode(low, v, high) { } } else { var n_2 = (nodeC.contents = nodeC.contents + 1 | 0, nodeC.contents); - var n$1 = { - TAG: "Node", + var n$1 = /* Node */{ _0: low, _1: v, _2: n_2, @@ -218,7 +217,7 @@ function hash(x, y) { } function not(n) { - if (typeof n !== "object") { + if (typeof n === "string") { if (n === "One") { return "Zero"; } else { @@ -237,7 +236,7 @@ function not(n) { } function and2(n1, n2) { - if (typeof n1 !== "object") { + if (typeof n1 === "string") { if (n1 === "One") { return n2; } else { @@ -248,7 +247,7 @@ function and2(n1, n2) { var i1 = n1._2; var v1 = n1._1; var l1 = n1._0; - if (typeof n2 !== "object") { + if (typeof n2 === "string") { if (n2 === "One") { return n1; } else { @@ -284,7 +283,7 @@ function and2(n1, n2) { } function xor(n1, n2) { - if (typeof n1 !== "object") { + if (typeof n1 === "string") { if (n1 === "One") { return not(n2); } else { @@ -295,7 +294,7 @@ function xor(n1, n2) { var i1 = n1._2; var v1 = n1._1; var l1 = n1._0; - if (typeof n2 !== "object") { + if (typeof n2 === "string") { if (n2 === "One") { return not(n1); } else { diff --git a/jscomp/test/defunctor_make_test.js b/jscomp/test/defunctor_make_test.js index 12d0b76fc6..9d50a32496 100644 --- a/jscomp/test/defunctor_make_test.js +++ b/jscomp/test/defunctor_make_test.js @@ -16,7 +16,7 @@ var Comparable = { }; function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._4; @@ -26,8 +26,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -38,11 +37,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -56,7 +55,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -66,8 +65,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -75,7 +73,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -89,7 +87,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -100,9 +98,8 @@ function bal(l, x, d, r) { } function add(x, data, compare, param) { - if (typeof param !== "object") { - return { - TAG: "Node", + if (typeof param === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -116,8 +113,7 @@ function add(x, data, compare, param) { var l = param._0; var c = compare(x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, diff --git a/jscomp/test/demo_int_map.js b/jscomp/test/demo_int_map.js index 9480d86069..4e5e534d68 100644 --- a/jscomp/test/demo_int_map.js +++ b/jscomp/test/demo_int_map.js @@ -2,7 +2,7 @@ function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -12,8 +12,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -24,11 +23,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -42,7 +41,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -52,8 +51,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -61,7 +59,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -75,7 +73,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -86,9 +84,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -105,8 +102,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -134,7 +130,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index d100c75bb8..2b55d2649d 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -21,11 +21,10 @@ function sum(n) { } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Nil"; } else { - return { - TAG: "Cons", + return /* Cons */{ _0: Curry._1(f, param._0), _1: map(f, param._1) }; diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index c8e968b4e5..1f727340c7 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -9,7 +9,7 @@ function sub(_tr, _k) { while(true) { var k = _k; var tr = _tr; - if (typeof tr !== "object") { + if (typeof tr === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -30,10 +30,9 @@ function sub(_tr, _k) { } function update(tr, k, w) { - if (typeof tr !== "object") { + if (typeof tr === "string") { if (k === 1) { - return { - TAG: "Br", + return /* Br */{ _0: w, _1: "Lf", _2: "Lf" @@ -47,8 +46,7 @@ function update(tr, k, w) { var r = tr._2; var l = tr._1; if (k === 1) { - return { - TAG: "Br", + return /* Br */{ _0: w, _1: l, _2: r @@ -56,15 +54,13 @@ function update(tr, k, w) { } var v = tr._0; if (k % 2 === 0) { - return { - TAG: "Br", + return /* Br */{ _0: v, _1: update(l, k / 2 | 0, w), _2: r }; } else { - return { - TAG: "Br", + return /* Br */{ _0: v, _1: l, _2: update(r, k / 2 | 0, w) @@ -73,7 +69,7 @@ function update(tr, k, w) { } function $$delete(tr, n) { - if (typeof tr !== "object") { + if (typeof tr === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -86,15 +82,13 @@ function $$delete(tr, n) { var l = tr._1; var v = tr._0; if (n % 2 === 0) { - return { - TAG: "Br", + return /* Br */{ _0: v, _1: $$delete(l, n / 2 | 0), _2: r }; } else { - return { - TAG: "Br", + return /* Br */{ _0: v, _1: l, _2: $$delete(r, n / 2 | 0) @@ -103,16 +97,14 @@ function $$delete(tr, n) { } function loext(tr, w) { - if (typeof tr !== "object") { - return { - TAG: "Br", + if (typeof tr === "string") { + return /* Br */{ _0: w, _1: "Lf", _2: "Lf" }; } else { - return { - TAG: "Br", + return /* Br */{ _0: w, _1: loext(tr._2, tr._0), _2: tr._1 @@ -121,23 +113,22 @@ function loext(tr, w) { } function lorem(tr) { - if (typeof tr !== "object") { + if (typeof tr === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = tr._1; - if (typeof l === "object") { - return { - TAG: "Br", + if (typeof l !== "string") { + return /* Br */{ _0: l._0, _1: tr._2, _2: lorem(l) }; } var tmp = tr._2; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return "Lf"; } throw { diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 1e32935ee4..8f42086840 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -84,7 +84,7 @@ function btwn_exclusive(loc1, loc2) { } function string_of_filename(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "(global)"; } else { return param._0; @@ -92,7 +92,7 @@ function string_of_filename(param) { } function order_of_filename(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 1; } switch (param.TAG) { @@ -1500,7 +1500,7 @@ Caml_module.update_mod({ }, Class, Class); function token_to_string(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "T_IDENTIFIER" : return "T_IDENTIFIER"; @@ -1824,7 +1824,7 @@ function get_result_and_clear_state(param) { var env = match[0]; var match$1; var exit = 0; - if (typeof lex_token !== "object") { + if (typeof lex_token === "string") { exit = 2; } else { switch (lex_token.TAG) { @@ -3211,71 +3211,78 @@ function token(env, lexbuf) { }; } -function regexp_class(env, buf, lexbuf) { - var ___ocaml_lex_state = 326; +function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - return env; + Lexing.new_line(lexbuf); + ___ocaml_lex_state = 393; + continue ; case 1 : + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 393; + continue ; case 2 : - break; + var start = from_lb(env.lex_source, lexbuf); + var buf = $$Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 393; + _env = env$1; + continue ; case 3 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - return env; + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = $$Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 393; + _env = env$2; + continue ; case 4 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$1); - return regexp_class(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - $$Buffer.add_string(buf, s); - return regexp_class(env, buf, lexbuf); - }; -} - -function line_comment(env, buf, lexbuf) { - var ___ocaml_lex_state = 287; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : + var start$2 = from_lb(env.lex_source, lexbuf); + var cooked = $$Buffer.create(127); + var raw = $$Buffer.create(127); + var literal = $$Buffer.create(127); + $$Buffer.add_string(literal, "}"); + var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); return [ - env, - from_lb(env.lex_source, lexbuf) + match$2[0], + { + TAG: "T_TEMPLATE_PART", + _0: [ + match$2[1], + { + cooked: $$Buffer.contents(cooked), + raw: $$Buffer.contents(raw), + literal: $$Buffer.contents(literal) + }, + match$2[2] + ] + } ]; - case 1 : - var match = from_lb(env.lex_source, lexbuf); - var match$1 = match._end; - Lexing.new_line(lexbuf); - var _end_line = match$1.line; - var _end_column = match$1.column - 1 | 0; - var _end_offset = match$1.offset - 1 | 0; - var _end = { - line: _end_line, - column: _end_column, - offset: _end_offset - }; + case 5 : + var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); return [ - env, + env$3, { - source: match.source, - start: match.start, - _end: _end + TAG: "T_TEMPLATE_PART", + _0: [ + from_lb(env$3.lex_source, lexbuf), + { + cooked: "", + raw: "", + literal: "" + }, + true + ] } ]; - case 2 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - return line_comment(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -3350,50 +3357,41 @@ function template_part(env, start, cooked, raw, literal, lexbuf) { }; } -function string_quote(env, q, buf, raw, octal, lexbuf) { - var ___ocaml_lex_state = 247; +function line_comment(env, buf, lexbuf) { + var ___ocaml_lex_state = 287; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - var q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, q$p); - if (q === q$p) { - return [ - env, - from_lb(env.lex_source, lexbuf), - octal - ]; - } else { - $$Buffer.add_char(buf, q$p); - return string_quote(env, q, buf, raw, octal, lexbuf); - } + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; case 1 : - var e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, e); - var match = string_escape(env, buf, lexbuf); - var octal$1 = match[1] || octal; - $$Buffer.add_string(raw, Lexing.lexeme(lexbuf)); - return string_quote(match[0], q, buf, raw, octal$1, lexbuf); - case 2 : - var x = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, x); - var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); - $$Buffer.add_string(buf, x); + var match = from_lb(env.lex_source, lexbuf); + var match$1 = match._end; + Lexing.new_line(lexbuf); + var _end_line = match$1.line; + var _end_column = match$1.column - 1 | 0; + var _end_offset = match$1.offset - 1 | 0; + var _end = { + line: _end_line, + column: _end_column, + offset: _end_offset + }; return [ - env$1, - from_lb(env$1.lex_source, lexbuf), - octal + env, + { + source: match.source, + start: match.start, + _end: _end + } ]; - case 3 : - var x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, x$1); - $$Buffer.add_char(buf, x$1); - return string_quote(env, q, buf, raw, octal, lexbuf); + case 2 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + return line_comment(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -3450,365 +3448,219 @@ function comment(env, buf, lexbuf) { }; } -function type_token(env, lexbuf) { - lexbuf.lex_mem = Caml_array.make(26, -1); - Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); - var ___ocaml_lex_state = 133; +function string_quote(env, q, buf, raw, octal, lexbuf) { + var ___ocaml_lex_state = 247; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - Lexing.new_line(lexbuf); - return type_token(env, lexbuf); + var q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, q$p); + if (q === q$p) { + return [ + env, + from_lb(env.lex_source, lexbuf), + octal + ]; + } else { + $$Buffer.add_char(buf, q$p); + return string_quote(env, q, buf, raw, octal, lexbuf); + } case 1 : - unicode_fix_cols(lexbuf); - return type_token(env, lexbuf); + var e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, e); + var match = string_escape(env, buf, lexbuf); + var octal$1 = match[1] || octal; + $$Buffer.add_string(raw, Lexing.lexeme(lexbuf)); + return string_quote(match[0], q, buf, raw, octal$1, lexbuf); case 2 : - var start = from_lb(env.lex_source, lexbuf); - var buf = $$Buffer.create(127); - var match = comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - return type_token(env$1, lexbuf); + var x = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, x); + var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); + $$Buffer.add_string(buf, x); + return [ + env$1, + from_lb(env$1.lex_source, lexbuf), + octal + ]; case 3 : - var sp = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); - var escape_type = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - var pattern = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - if (env.lex_enable_comment_syntax) { - var env$2; - if (env.lex_in_comment_syntax) { - var loc = from_lb(env.lex_source, lexbuf); - env$2 = unexpected_error(env, loc, pattern); - } else { - env$2 = env; - } - var env$3 = in_comment_syntax(true, env$2); - if (escape_type === ":") { - return [ - env$3, - "T_COLON" - ]; - } else { - return type_token(env$3, lexbuf); - } - } - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = $$Buffer.create(127); - $$Buffer.add_string(buf$1, sp); - $$Buffer.add_string(buf$1, escape_type); - var match$1 = comment(env, buf$1, lexbuf); - var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - return type_token(env$4, lexbuf); - case 4 : - if (env.lex_in_comment_syntax) { - var env$5 = in_comment_syntax(false, env); - return type_token(env$5, lexbuf); - } - yyback(1, lexbuf); - return [ - env, - "T_MULT" - ]; - case 5 : - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = $$Buffer.create(127); - var match$2 = line_comment(env, buf$2, lexbuf); - var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); - return type_token(env$6, lexbuf); - case 6 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$3 = from_lb(env.lex_source, lexbuf); - var buf$3 = $$Buffer.create(127); - var raw = $$Buffer.create(127); - $$Buffer.add_char(raw, quote); - var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); - return [ - match$3[0], - { - TAG: "T_STRING", - _0: [ - btwn(start$3, match$3[1]), - $$Buffer.contents(buf$3), - $$Buffer.contents(raw), - match$3[2] - ] - } - ]; - case 7 : - var neg = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w, mk_num_singleton("BINARY", num, neg)); - case 8 : - var neg$1 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + var x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, x$1); + $$Buffer.add_char(buf, x$1); + return string_quote(env, q, buf, raw, octal, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function string_escape(env, buf, lexbuf) { + var ___ocaml_lex_state = 252; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : return [ env, - mk_num_singleton("BINARY", num$1, neg$1) + false ]; - case 9 : - var neg$2 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$1, mk_num_singleton("OCTAL", num$2, neg$2)); - case 10 : - var neg$3 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 1 : + $$Buffer.add_string(buf, "\\"); return [ env, - mk_num_singleton("OCTAL", num$3, neg$3) + false ]; - case 11 : - var neg$4 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$2, mk_num_singleton("LEGACY_OCTAL", num$4, neg$4)); - case 12 : - var neg$5 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + case 2 : + var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code)); return [ env, - mk_num_singleton("LEGACY_OCTAL", num$5, neg$5) + false ]; - case 13 : - var neg$6 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$6 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - var match$4; - try { - match$4 = [ - env, - mk_num_singleton("NORMAL", num$6, neg$6) - ]; - } - catch (exn){ - if (Sys.win32) { - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$7 = lex_error(env, loc$1, "WindowsFloatOfString"); - match$4 = [ - env$7, - { - TAG: "T_NUMBER_SINGLETON_TYPE", - _0: "NORMAL", - _1: 789.0 - } - ]; - } else { - throw exn; - } - } - return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); - case 14 : - var neg$7 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$7 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - try { - return [ - env, - mk_num_singleton("NORMAL", num$7, neg$7) - ]; - } - catch (exn$1){ - if (Sys.win32) { - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$8 = lex_error(env, loc$2, "WindowsFloatOfString"); - return [ - env$8, - { - TAG: "T_NUMBER_SINGLETON_TYPE", - _0: "NORMAL", - _1: 789.0 - } - ]; - } - throw exn$1; + case 3 : + var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; + if (code$1 < 256) { + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$1)); + } else { + var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$2)); + $$Buffer.add_char(buf, c); } - case 15 : - var neg$8 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$8 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$4, mk_num_singleton("NORMAL", num$8, neg$8)); - case 16 : - var neg$9 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$9 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - mk_num_singleton("NORMAL", num$9, neg$9) + true ]; - case 17 : - var neg$10 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$10 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$5, mk_num_singleton("NORMAL", num$10, neg$10)); - case 18 : - var neg$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); - var num$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); + case 4 : + var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$3)); return [ env, - mk_num_singleton("NORMAL", num$11, neg$11) + true ]; - case 19 : - var word = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - unicode_fix_cols(lexbuf); - try { - return [ - env, - Hashtbl.find(type_keywords, word) - ]; - } - catch (raw_exn){ - var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$2.RE_EXN_ID === "Not_found") { - return [ - env, - "T_IDENTIFIER" - ]; - } - throw exn$2; - } - case 22 : + case 5 : + $$Buffer.add_char(buf, Char.chr(0)); return [ env, - "T_LCURLY" + false ]; - case 23 : + case 6 : + $$Buffer.add_char(buf, Char.chr(8)); return [ env, - "T_RCURLY" + false ]; - case 24 : + case 7 : + $$Buffer.add_char(buf, Char.chr(12)); return [ env, - "T_LPAREN" + false ]; - case 25 : + case 8 : + $$Buffer.add_char(buf, Char.chr(10)); return [ env, - "T_RPAREN" + false ]; - case 26 : + case 9 : + $$Buffer.add_char(buf, Char.chr(13)); return [ env, - "T_ELLIPSIS" + false ]; - case 27 : + case 10 : + $$Buffer.add_char(buf, Char.chr(9)); return [ env, - "T_PERIOD" + false ]; - case 28 : + case 11 : + $$Buffer.add_char(buf, Char.chr(11)); return [ env, - "T_SEMICOLON" + false ]; - case 29 : + case 12 : + var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var code$4 = oct_to_int(a$3); + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$4)); return [ env, - "T_COMMA" + true ]; - case 20 : - case 32 : - return [ - env, - "T_LBRACKET" - ]; - case 21 : - case 33 : - return [ - env, - "T_RBRACKET" - ]; - case 34 : - return [ - env, - "T_LESS_THAN" - ]; - case 35 : - return [ - env, - "T_GREATER_THAN" - ]; - case 31 : - case 37 : - return [ - env, - "T_PLING" - ]; - case 38 : - return [ - env, - "T_MULT" - ]; - case 30 : - case 39 : - return [ - env, - "T_COLON" - ]; - case 40 : - return [ - env, - "T_BIT_OR" - ]; - case 41 : - return [ - env, - "T_BIT_AND" - ]; - case 42 : - return [ - env, - "T_TYPEOF" - ]; - case 43 : + case 13 : + var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); + var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); + var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$5)); return [ env, - "T_ARROW" + false ]; - case 36 : - case 44 : + case 14 : + var hex_code = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); + var code$6 = Caml_format.int_of_string("0x" + hex_code); + var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }) : env; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$6)); return [ - env, - "T_ASSIGN" + env$1, + false ]; - case 45 : + case 15 : + var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); + $$Buffer.add_char(buf, c$2); return [ - env, - "T_PLUS" + env$2, + false ]; - case 46 : + case 16 : + Lexing.new_line(lexbuf); return [ env, - "T_MINUS" - ]; - case 47 : - var env$9; - if (env.lex_in_comment_syntax) { - var loc$3 = from_lb(env.lex_source, lexbuf); - env$9 = lex_error(env, loc$3, "UnexpectedEOS"); - } else { - env$9 = env; - } - return [ - env$9, - "T_EOF" + false ]; - case 48 : + case 17 : + var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$3); return [ env, - "T_ERROR" + false ]; default: Curry._1(lexbuf.refill_buff, lexbuf); @@ -3818,77 +3670,108 @@ function type_token(env, lexbuf) { }; } -function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { +function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var env = _env; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : + return [ + env, + "T_EOF" + ]; + case 1 : Lexing.new_line(lexbuf); - ___ocaml_lex_state = 393; + ___ocaml_lex_state = 333; continue ; - case 1 : + case 2 : unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 393; + ___ocaml_lex_state = 333; continue ; - case 2 : + case 3 : var start = from_lb(env.lex_source, lexbuf); var buf = $$Buffer.create(127); var match = line_comment(env, buf, lexbuf); var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 393; + ___ocaml_lex_state = 333; _env = env$1; continue ; - case 3 : + case 4 : var start$1 = from_lb(env.lex_source, lexbuf); var buf$1 = $$Buffer.create(127); var match$1 = comment(env, buf$1, lexbuf); var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 393; + ___ocaml_lex_state = 333; _env = env$2; continue ; - case 4 : + case 5 : + return [ + env, + "T_LESS_THAN" + ]; + case 6 : + return [ + env, + "T_DIV" + ]; + case 7 : + return [ + env, + "T_GREATER_THAN" + ]; + case 8 : + return [ + env, + "T_LCURLY" + ]; + case 9 : + return [ + env, + "T_COLON" + ]; + case 10 : + return [ + env, + "T_PERIOD" + ]; + case 11 : + return [ + env, + "T_ASSIGN" + ]; + case 12 : + unicode_fix_cols(lexbuf); + return [ + env, + "T_JSX_IDENTIFIER" + ]; + case 13 : + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); var start$2 = from_lb(env.lex_source, lexbuf); - var cooked = $$Buffer.create(127); + var buf$2 = $$Buffer.create(127); var raw = $$Buffer.create(127); - var literal = $$Buffer.create(127); - $$Buffer.add_string(literal, "}"); - var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); + $$Buffer.add_char(raw, quote); + var mode = quote === /* '\'' */39 ? "JSX_SINGLE_QUOTED_TEXT" : "JSX_DOUBLE_QUOTED_TEXT"; + var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); + $$Buffer.add_char(raw, quote); + var value = $$Buffer.contents(buf$2); + var raw$1 = $$Buffer.contents(raw); return [ match$2[0], { - TAG: "T_TEMPLATE_PART", + TAG: "T_JSX_TEXT", _0: [ - match$2[1], - { - cooked: $$Buffer.contents(cooked), - raw: $$Buffer.contents(raw), - literal: $$Buffer.contents(literal) - }, - match$2[2] + btwn(start$2, match$2[1]), + value, + raw$1 ] } ]; - case 5 : - var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); + case 14 : return [ - env$3, - { - TAG: "T_TEMPLATE_PART", - _0: [ - from_lb(env$3.lex_source, lexbuf), - { - cooked: "", - raw: "", - literal: "" - }, - true - ] - } + env, + "T_ERROR" ]; default: Curry._1(lexbuf.refill_buff, lexbuf); @@ -4763,279 +4646,87 @@ function jsx_text(env, mode, buf, raw, lexbuf) { }; } -function string_escape(env, buf, lexbuf) { - var ___ocaml_lex_state = 252; +function regexp_class(env, buf, lexbuf) { + var ___ocaml_lex_state = 326; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - return [ - env, - false - ]; + return env; case 1 : - $$Buffer.add_string(buf, "\\"); - return [ - env, - false - ]; case 2 : - var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code)); - return [ - env, - false - ]; + break; case 3 : - var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; - if (code$1 < 256) { - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$1)); - } else { - var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$2)); - $$Buffer.add_char(buf, c); - } - return [ - env, - true - ]; + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + return env; case 4 : - var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$3)); - return [ - env, - true - ]; - case 5 : - $$Buffer.add_char(buf, Char.chr(0)); - return [ - env, - false - ]; - case 6 : - $$Buffer.add_char(buf, Char.chr(8)); - return [ - env, - false - ]; - case 7 : - $$Buffer.add_char(buf, Char.chr(12)); - return [ - env, - false - ]; - case 8 : - $$Buffer.add_char(buf, Char.chr(10)); - return [ - env, - false - ]; - case 9 : - $$Buffer.add_char(buf, Char.chr(13)); - return [ - env, - false - ]; - case 10 : - $$Buffer.add_char(buf, Char.chr(9)); - return [ - env, - false - ]; - case 11 : - $$Buffer.add_char(buf, Char.chr(11)); - return [ - env, - false - ]; - case 12 : - var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var code$4 = oct_to_int(a$3); - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$4)); - return [ - env, - true - ]; - case 13 : - var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); - var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); - var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$5)); - return [ - env, - false - ]; - case 14 : - var hex_code = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); - var code$6 = Caml_format.int_of_string("0x" + hex_code); - var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }) : env; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$6)); - return [ - env$1, - false - ]; - case 15 : - var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); - $$Buffer.add_char(buf, c$2); - return [ - env$2, - false - ]; - case 16 : - Lexing.new_line(lexbuf); - return [ - env, - false - ]; - case 17 : - var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$3); - return [ - env, - false - ]; + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$1); + return regexp_class(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue ; } + var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + $$Buffer.add_string(buf, s); + return regexp_class(env, buf, lexbuf); }; } -function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { +function regexp_body(env, buf, lexbuf) { + var ___ocaml_lex_state = 314; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : + var loc = from_lb(env.lex_source, lexbuf); + var env$1 = lex_error(env, loc, "UnterminatedRegExp"); return [ - env, - "T_EOF" + env$1, + "" ]; case 1 : - Lexing.new_line(lexbuf); - ___ocaml_lex_state = 333; - continue ; - case 2 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 333; - continue ; - case 3 : - var start = from_lb(env.lex_source, lexbuf); - var buf = $$Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 333; - _env = env$1; - continue ; - case 4 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = $$Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 333; - _env = env$2; - continue ; - case 5 : - return [ - env, - "T_LESS_THAN" - ]; - case 6 : - return [ - env, - "T_DIV" - ]; - case 7 : - return [ - env, - "T_GREATER_THAN" - ]; - case 8 : - return [ - env, - "T_LCURLY" - ]; - case 9 : - return [ - env, - "T_COLON" - ]; - case 10 : + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$2 = lex_error(env, loc$1, "UnterminatedRegExp"); return [ - env, - "T_PERIOD" + env$2, + "" ]; - case 11 : + case 2 : + var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + $$Buffer.add_string(buf, s); + return regexp_body(env, buf, lexbuf); + case 3 : + var flags = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); return [ env, - "T_ASSIGN" + flags ]; - case 12 : - unicode_fix_cols(lexbuf); + case 4 : return [ env, - "T_JSX_IDENTIFIER" - ]; - case 13 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = $$Buffer.create(127); - var raw = $$Buffer.create(127); - $$Buffer.add_char(raw, quote); - var mode = quote === /* '\'' */39 ? "JSX_SINGLE_QUOTED_TEXT" : "JSX_DOUBLE_QUOTED_TEXT"; - var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); - $$Buffer.add_char(raw, quote); - var value = $$Buffer.contents(buf$2); - var raw$1 = $$Buffer.contents(raw); - return [ - match$2[0], - { - TAG: "T_JSX_TEXT", - _0: [ - btwn(start$2, match$2[1]), - value, - raw$1 - ] - } + "" ]; - case 14 : + case 5 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + var env$3 = regexp_class(env, buf, lexbuf); + return regexp_body(env$3, buf, lexbuf); + case 6 : + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$4 = lex_error(env, loc$2, "UnterminatedRegExp"); return [ - env, - "T_ERROR" + env$4, + "" ]; + case 7 : + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$1); + return regexp_body(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -5114,124 +4805,433 @@ function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { }; } -function regexp_body(env, buf, lexbuf) { - var ___ocaml_lex_state = 314; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var loc = from_lb(env.lex_source, lexbuf); - var env$1 = lex_error(env, loc, "UnterminatedRegExp"); - return [ - env$1, - "" - ]; +function type_token(env, lexbuf) { + lexbuf.lex_mem = Caml_array.make(26, -1); + Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); + var ___ocaml_lex_state = 133; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + Lexing.new_line(lexbuf); + return type_token(env, lexbuf); case 1 : - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$2 = lex_error(env, loc$1, "UnterminatedRegExp"); - return [ - env$2, - "" - ]; + unicode_fix_cols(lexbuf); + return type_token(env, lexbuf); case 2 : - var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - $$Buffer.add_string(buf, s); - return regexp_body(env, buf, lexbuf); + var start = from_lb(env.lex_source, lexbuf); + var buf = $$Buffer.create(127); + var match = comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + return type_token(env$1, lexbuf); case 3 : - var flags = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); - return [ - env, - flags - ]; + var sp = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); + var escape_type = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + var pattern = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + if (env.lex_enable_comment_syntax) { + var env$2; + if (env.lex_in_comment_syntax) { + var loc = from_lb(env.lex_source, lexbuf); + env$2 = unexpected_error(env, loc, pattern); + } else { + env$2 = env; + } + var env$3 = in_comment_syntax(true, env$2); + if (escape_type === ":") { + return [ + env$3, + "T_COLON" + ]; + } else { + return type_token(env$3, lexbuf); + } + } + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = $$Buffer.create(127); + $$Buffer.add_string(buf$1, sp); + $$Buffer.add_string(buf$1, escape_type); + var match$1 = comment(env, buf$1, lexbuf); + var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + return type_token(env$4, lexbuf); case 4 : + if (env.lex_in_comment_syntax) { + var env$5 = in_comment_syntax(false, env); + return type_token(env$5, lexbuf); + } + yyback(1, lexbuf); return [ env, - "" + "T_MULT" ]; case 5 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - var env$3 = regexp_class(env, buf, lexbuf); - return regexp_body(env$3, buf, lexbuf); + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = $$Buffer.create(127); + var match$2 = line_comment(env, buf$2, lexbuf); + var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); + return type_token(env$6, lexbuf); case 6 : - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$4 = lex_error(env, loc$2, "UnterminatedRegExp"); - return [ - env$4, - "" - ]; - case 7 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$1); - return regexp_body(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function jsx_child(env, start, buf, raw, lexbuf) { - var ___ocaml_lex_state = 364; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, lt); - $$Buffer.add_string(buf, lt); - Lexing.new_line(lexbuf); - var match = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); - var value = $$Buffer.contents(buf); - var raw$1 = $$Buffer.contents(raw); + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var start$3 = from_lb(env.lex_source, lexbuf); + var buf$3 = $$Buffer.create(127); + var raw = $$Buffer.create(127); + $$Buffer.add_char(raw, quote); + var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); return [ - match[0], + match$3[0], { - TAG: "T_JSX_TEXT", + TAG: "T_STRING", _0: [ - btwn(start, match[1]), - value, - raw$1 + btwn(start$3, match$3[1]), + $$Buffer.contents(buf$3), + $$Buffer.contents(raw), + match$3[2] ] } ]; - case 1 : + case 7 : + var neg = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w, mk_num_singleton("BINARY", num, neg)); + case 8 : + var neg$1 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - "T_EOF" + mk_num_singleton("BINARY", num$1, neg$1) ]; - case 2 : + case 9 : + var neg$2 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$1, mk_num_singleton("OCTAL", num$2, neg$2)); + case 10 : + var neg$3 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - "T_LESS_THAN" + mk_num_singleton("OCTAL", num$3, neg$3) ]; - case 3 : + case 11 : + var neg$4 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$2, mk_num_singleton("LEGACY_OCTAL", num$4, neg$4)); + case 12 : + var neg$5 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - "T_LCURLY" + mk_num_singleton("LEGACY_OCTAL", num$5, neg$5) ]; - case 4 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, c); - $$Buffer.add_char(buf, c); - var match$1 = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); - var value$1 = $$Buffer.contents(buf); - var raw$2 = $$Buffer.contents(raw); + case 13 : + var neg$6 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$6 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + var match$4; + try { + match$4 = [ + env, + mk_num_singleton("NORMAL", num$6, neg$6) + ]; + } + catch (exn){ + if (Sys.win32) { + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$7 = lex_error(env, loc$1, "WindowsFloatOfString"); + match$4 = [ + env$7, + { + TAG: "T_NUMBER_SINGLETON_TYPE", + _0: "NORMAL", + _1: 789.0 + } + ]; + } else { + throw exn; + } + } + return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); + case 14 : + var neg$7 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$7 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + try { + return [ + env, + mk_num_singleton("NORMAL", num$7, neg$7) + ]; + } + catch (exn$1){ + if (Sys.win32) { + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$8 = lex_error(env, loc$2, "WindowsFloatOfString"); + return [ + env$8, + { + TAG: "T_NUMBER_SINGLETON_TYPE", + _0: "NORMAL", + _1: 789.0 + } + ]; + } + throw exn$1; + } + case 15 : + var neg$8 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$8 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$4, mk_num_singleton("NORMAL", num$8, neg$8)); + case 16 : + var neg$9 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$9 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ - match$1[0], - { - TAG: "T_JSX_TEXT", - _0: [ - btwn(start, match$1[1]), - value$1, - raw$2 - ] - } + env, + mk_num_singleton("NORMAL", num$9, neg$9) ]; - default: + case 17 : + var neg$10 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$10 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$5, mk_num_singleton("NORMAL", num$10, neg$10)); + case 18 : + var neg$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); + var num$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); + return [ + env, + mk_num_singleton("NORMAL", num$11, neg$11) + ]; + case 19 : + var word = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + unicode_fix_cols(lexbuf); + try { + return [ + env, + Hashtbl.find(type_keywords, word) + ]; + } + catch (raw_exn){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn$2.RE_EXN_ID === "Not_found") { + return [ + env, + "T_IDENTIFIER" + ]; + } + throw exn$2; + } + case 22 : + return [ + env, + "T_LCURLY" + ]; + case 23 : + return [ + env, + "T_RCURLY" + ]; + case 24 : + return [ + env, + "T_LPAREN" + ]; + case 25 : + return [ + env, + "T_RPAREN" + ]; + case 26 : + return [ + env, + "T_ELLIPSIS" + ]; + case 27 : + return [ + env, + "T_PERIOD" + ]; + case 28 : + return [ + env, + "T_SEMICOLON" + ]; + case 29 : + return [ + env, + "T_COMMA" + ]; + case 20 : + case 32 : + return [ + env, + "T_LBRACKET" + ]; + case 21 : + case 33 : + return [ + env, + "T_RBRACKET" + ]; + case 34 : + return [ + env, + "T_LESS_THAN" + ]; + case 35 : + return [ + env, + "T_GREATER_THAN" + ]; + case 31 : + case 37 : + return [ + env, + "T_PLING" + ]; + case 38 : + return [ + env, + "T_MULT" + ]; + case 30 : + case 39 : + return [ + env, + "T_COLON" + ]; + case 40 : + return [ + env, + "T_BIT_OR" + ]; + case 41 : + return [ + env, + "T_BIT_AND" + ]; + case 42 : + return [ + env, + "T_TYPEOF" + ]; + case 43 : + return [ + env, + "T_ARROW" + ]; + case 36 : + case 44 : + return [ + env, + "T_ASSIGN" + ]; + case 45 : + return [ + env, + "T_PLUS" + ]; + case 46 : + return [ + env, + "T_MINUS" + ]; + case 47 : + var env$9; + if (env.lex_in_comment_syntax) { + var loc$3 = from_lb(env.lex_source, lexbuf); + env$9 = lex_error(env, loc$3, "UnexpectedEOS"); + } else { + env$9 = env; + } + return [ + env$9, + "T_EOF" + ]; + case 48 : + return [ + env, + "T_ERROR" + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function jsx_child(env, start, buf, raw, lexbuf) { + var ___ocaml_lex_state = 364; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, lt); + $$Buffer.add_string(buf, lt); + Lexing.new_line(lexbuf); + var match = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); + var value = $$Buffer.contents(buf); + var raw$1 = $$Buffer.contents(raw); + return [ + match[0], + { + TAG: "T_JSX_TEXT", + _0: [ + btwn(start, match[1]), + value, + raw$1 + ] + } + ]; + case 1 : + return [ + env, + "T_EOF" + ]; + case 2 : + return [ + env, + "T_LESS_THAN" + ]; + case 3 : + return [ + env, + "T_LCURLY" + ]; + case 4 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, c); + $$Buffer.add_char(buf, c); + var match$1 = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); + var value$1 = $$Buffer.contents(buf); + var raw$2 = $$Buffer.contents(raw); + return [ + match$1[0], + { + TAG: "T_JSX_TEXT", + _0: [ + btwn(start, match$1[1]), + value$1, + raw$2 + ] + } + ]; + default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue ; @@ -5271,7 +5271,7 @@ function token$1(env) { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -5280,11 +5280,10 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -5294,11 +5293,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -5311,7 +5310,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -5321,15 +5320,14 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -5342,7 +5340,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -5353,9 +5351,8 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -5388,7 +5385,7 @@ function add(x, t) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.string_compare(x, param.v); @@ -5523,7 +5520,7 @@ function init_env(token_sinkOpt, parse_optionsOpt, source, content) { var token_sink = token_sinkOpt !== undefined ? Caml_option.valFromOption(token_sinkOpt) : undefined; var parse_options = parse_optionsOpt !== undefined ? Caml_option.valFromOption(parse_optionsOpt) : undefined; var lb = Lexing.from_string(content); - if (source !== undefined && typeof source === "object") { + if (source !== undefined && typeof source !== "string") { var init = lb.lex_curr_p; lb.lex_curr_p = { pos_fname: source._0, @@ -5826,7 +5823,7 @@ function is_line_terminator(env) { function is_implicit_semicolon(env) { var match = token$2(undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return is_line_terminator(env); } switch (match) { @@ -5855,7 +5852,7 @@ function is_identifier(iOpt, env) { if (is_strict_reserved(name) || is_restricted(name) || is_future_reserved(name)) { return true; } - if (typeof match === "object") { + if (typeof match !== "string") { return false; } switch (match) { @@ -5886,7 +5883,7 @@ function is_function(iOpt, env) { function is_class(iOpt, env) { var i = iOpt !== undefined ? iOpt : 0; var match = token$2(i, env); - if (typeof match === "object") { + if (typeof match !== "string") { return false; } switch (match) { @@ -5908,7 +5905,7 @@ function error(env, e) { function get_unexpected_error(param) { var tmp = param[0]; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { switch (tmp) { case "T_IDENTIFIER" : return "UnexpectedIdentifier"; @@ -6134,8 +6131,7 @@ function to_parse(env, parse) { try { var result = Curry._1(parse, env); reset_token_sink(true, env, saved_state.token_buffer); - return { - TAG: "ParsedSuccessfully", + return /* ParsedSuccessfully */{ _0: result }; } @@ -6175,7 +6171,7 @@ var Parser_env_Try = { }; function height$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -6184,11 +6180,10 @@ function height$1(param) { function create$2(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -6198,11 +6193,11 @@ function create$2(l, v, r) { function bal$1(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6215,7 +6210,7 @@ function bal$1(l, v, r) { if (height$1(ll) >= height$1(lr)) { return create$2(ll, lv, create$2(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$2(create$2(ll, lv, lr.l), lr.v, create$2(lr.r, v, r)); } throw { @@ -6225,15 +6220,14 @@ function bal$1(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6246,7 +6240,7 @@ function bal$1(l, v, r) { if (height$1(rr) >= height$1(rl)) { return create$2(create$2(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$2(create$2(l, v, rl.l), rl.v, create$2(rl.r, rv, rr)); } throw { @@ -6257,9 +6251,8 @@ function bal$1(l, v, r) { } function add$1(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -6292,7 +6285,7 @@ function add$1(x, t) { function mem$1(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.string_compare(x, param.v); @@ -6305,7 +6298,7 @@ function mem$1(x, _param) { } function height$2(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -6315,8 +6308,7 @@ function height$2(param) { function create$3(l, x, d, r) { var hl = height$2(l); var hr = height$2(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -6327,11 +6319,11 @@ function create$3(l, x, d, r) { function bal$2(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -6345,7 +6337,7 @@ function bal$2(l, x, d, r) { if (height$2(ll) >= height$2(lr)) { return create$3(ll, lv, ld, create$3(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$3(create$3(ll, lv, ld, lr.l), lr.v, lr.d, create$3(lr.r, x, d, r)); } throw { @@ -6355,8 +6347,7 @@ function bal$2(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -6364,7 +6355,7 @@ function bal$2(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -6378,7 +6369,7 @@ function bal$2(l, x, d, r) { if (height$2(rr) >= height$2(rl)) { return create$3(create$3(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$3(create$3(l, x, d, rl.l), rl.v, rl.d, create$3(rl.r, rv, rd, rr)); } throw { @@ -6389,9 +6380,8 @@ function bal$2(l, x, d, r) { } function add$2(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -6408,8 +6398,7 @@ function add$2(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -6437,7 +6426,7 @@ function add$2(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -6462,7 +6451,7 @@ function compare$1(param, param$1) { } function height$3(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -6471,11 +6460,10 @@ function height$3(param) { function create$4(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -6485,11 +6473,11 @@ function create$4(l, v, r) { function bal$3(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6502,7 +6490,7 @@ function bal$3(l, v, r) { if (height$3(ll) >= height$3(lr)) { return create$4(ll, lv, create$4(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$4(create$4(ll, lv, lr.l), lr.v, create$4(lr.r, v, r)); } throw { @@ -6512,15 +6500,14 @@ function bal$3(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6533,7 +6520,7 @@ function bal$3(l, v, r) { if (height$3(rr) >= height$3(rl)) { return create$4(create$4(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$4(create$4(l, v, rl.l), rl.v, create$4(rl.r, rv, rr)); } throw { @@ -6544,9 +6531,8 @@ function bal$3(l, v, r) { } function add$3(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -6579,7 +6565,7 @@ function add$3(x, t) { function mem$2(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = compare$1(x, param.v); @@ -6733,19 +6719,129 @@ var Parse = Caml_module.init_mod([ ] }); -function prefix(env) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { - return postfix(env); - } - if (match !== "T_PLING") { - return postfix(env); - } - var loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_PLING"); - var t = prefix(env); - return [ - btwn(loc, t[0]), +function union(env) { + maybe(env, "T_BIT_OR"); + var left = intersection(env); + return Curry._2(union_with, env, left); +} + +function param_list_or_type(env) { + token$4(env, "T_LPAREN"); + var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); + var ret; + var exit = 0; + if (typeof token$5 === "string") { + switch (token$5) { + case "T_IDENTIFIER" : + ret = function_param_or_generic_type(env); + break; + case "T_RPAREN" : + ret = { + TAG: "ParamList", + _0: [ + undefined, + /* [] */0 + ] + }; + break; + case "T_ELLIPSIS" : + case "T_EOF" : + ret = { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, /* [] */0) + }; + break; + default: + exit = 1; + } + } else { + exit = 1; + } + if (exit === 1) { + var match = primitive(token$5); + if (match !== undefined) { + var match$1 = Curry._2(Parser_env_Peek.token, 1, env); + var exit$1 = 0; + if (typeof match$1 === "string") { + switch (match$1) { + case "T_PLING" : + case "T_COLON" : + exit$1 = 2; + break; + default: + ret = { + TAG: "Type", + _0: union(env) + }; + } + } else { + ret = { + TAG: "Type", + _0: union(env) + }; + } + if (exit$1 === 2) { + var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var name = match$2[0]; + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + var optional = maybe(env, "T_PLING"); + token$4(env, "T_COLON"); + var typeAnnotation = union(env); + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RPAREN") { + token$4(env, "T_COMMA"); + } + var param_0 = btwn(name[0], typeAnnotation[0]); + var param_1 = { + name: name, + typeAnnotation: typeAnnotation, + optional: optional + }; + var param = [ + param_0, + param_1 + ]; + ret = { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + } + + } else { + ret = { + TAG: "Type", + _0: union(env) + }; + } + } + token$4(env, "T_RPAREN"); + return ret; +} + +function function_param_list(env) { + token$4(env, "T_LPAREN"); + var ret = Curry._2(function_param_list_without_parens, env, /* [] */0); + token$4(env, "T_RPAREN"); + return ret; +} + +function prefix(env) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "string") { + return postfix(env); + } + if (match !== "T_PLING") { + return postfix(env); + } + var loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_PLING"); + var t = prefix(env); + return [ + btwn(loc, t[0]), { TAG: "Nullable", _0: t @@ -6753,6 +6849,17 @@ function prefix(env) { ]; } +function postfix(env) { + var t = primary(env); + return postfix_with(env, t); +} + +function intersection(env) { + maybe(env, "T_BIT_AND"); + var left = prefix(env); + return Curry._2(intersection_with, env, left); +} + function rev_nonempty_acc(acc) { var end_loc; if (acc) { @@ -6789,34 +6896,119 @@ function rev_nonempty_acc(acc) { ]; } -function intersection(env) { - maybe(env, "T_BIT_AND"); - var left = prefix(env); - return Curry._2(intersection_with, env, left); +function function_param_with_id(env, name) { + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + var optional = maybe(env, "T_PLING"); + token$4(env, "T_COLON"); + var typeAnnotation = union(env); + return [ + btwn(name[0], typeAnnotation[0]), + { + name: name, + typeAnnotation: typeAnnotation, + optional: optional + } + ]; } -function function_param_list(env) { - token$4(env, "T_LPAREN"); - var ret = Curry._2(function_param_list_without_parens, env, /* [] */0); - token$4(env, "T_RPAREN"); - return ret; +function generic_type_with_identifier(env, id) { + var match = Curry._2(raw_generic_with_identifier, env, id); + return [ + match[0], + { + TAG: "Generic", + _0: match[1] + } + ]; } -function union(env) { - maybe(env, "T_BIT_OR"); - var left = intersection(env); - return Curry._2(union_with, env, left); +function postfix_with(env, _t) { + while(true) { + var t = _t; + if (!(!Curry._1(Parser_env_Peek.is_line_terminator, env) && maybe(env, "T_LBRACKET"))) { + return t; + } + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_RBRACKET"); + var loc = btwn(t[0], end_loc); + var t_1 = { + TAG: "Array", + _0: t + }; + var t$1 = [ + loc, + t_1 + ]; + _t = t$1; + continue ; + }; } -function generic(env) { - return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); +function primitive(param) { + if (typeof param !== "string") { + return ; + } + switch (param) { + case "T_NULL" : + return "Null"; + case "T_ANY_TYPE" : + return "Any"; + case "T_BOOLEAN_TYPE" : + return "Boolean"; + case "T_NUMBER_TYPE" : + return "Number"; + case "T_STRING_TYPE" : + return "String"; + case "T_VOID_TYPE" : + return "Void"; + default: + return ; + } +} + +function function_param_or_generic_type(env) { + var id = Curry._2(Parse.identifier, undefined, env); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var exit = 0; + if (typeof match === "string") { + switch (match) { + case "T_PLING" : + case "T_COLON" : + exit = 2; + break; + default: + exit = 1; + } + } else { + exit = 1; + } + switch (exit) { + case 1 : + return { + TAG: "Type", + _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) + }; + case 2 : + var param = function_param_with_id(env, id); + maybe(env, "T_COMMA"); + return { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + + } } function primary(env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof token$5 !== "object") { + if (typeof token$5 === "string") { switch (token$5) { case "T_IDENTIFIER" : var match = generic(env); @@ -7004,244 +7196,204 @@ function primary(env) { } } -function primitive(param) { - if (typeof param === "object") { - return ; - } - switch (param) { - case "T_NULL" : - return "Null"; - case "T_ANY_TYPE" : - return "Any"; - case "T_BOOLEAN_TYPE" : - return "Boolean"; - case "T_NUMBER_TYPE" : - return "Number"; - case "T_STRING_TYPE" : - return "String"; - case "T_VOID_TYPE" : - return "Void"; - default: - return ; - } +function generic(env) { + return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); } -function function_param_with_id(env, name) { - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); - } - var optional = maybe(env, "T_PLING"); - token$4(env, "T_COLON"); - var typeAnnotation = union(env); +function identifier(env, _param) { + while(true) { + var param = _param; + var qualification = param[1]; + var q_loc = param[0]; + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_PERIOD") { + return [ + q_loc, + qualification + ]; + } + token$4(env, "T_PERIOD"); + var id = Curry._2(Parse.identifier, undefined, env); + var loc = btwn(q_loc, id[0]); + var qualification$1 = { + TAG: "Qualified", + _0: [ + loc, + { + qualification: qualification, + id: id + } + ] + }; + _param = [ + loc, + qualification$1 + ]; + continue ; + }; +} + +function raw_generic_with_identifier(env, id) { + var id_0 = id[0]; + var id_1 = { + TAG: "Unqualified", + _0: id + }; + var id$1 = [ + id_0, + id_1 + ]; + var match = identifier(env, id$1); + var id_loc = match[0]; + var typeParameters = Curry._1(type_parameter_instantiation, env); + var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; return [ - btwn(name[0], typeAnnotation[0]), + loc, { - name: name, - typeAnnotation: typeAnnotation, - optional: optional + id: match[1], + typeParameters: typeParameters } ]; } -function postfix_with(env, _t) { +function params(env, allow_default, _require_default, _acc) { while(true) { - var t = _t; - if (!(!Curry._1(Parser_env_Peek.is_line_terminator, env) && maybe(env, "T_LBRACKET"))) { - return t; + var acc = _acc; + var require_default = _require_default; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var variance; + if (typeof match === "string") { + switch (match) { + case "T_PLUS" : + token$3(env); + variance = "Plus"; + break; + case "T_MINUS" : + token$3(env); + variance = "Minus"; + break; + default: + variance = undefined; + } + } else { + variance = undefined; } - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_RBRACKET"); - var loc = btwn(t[0], end_loc); - var t_1 = { - TAG: "Array", - _0: t + var match$1 = Curry._2(Parse.identifier_with_type, env, "StrictParamName"); + var id = match$1[1]; + var loc = match$1[0]; + var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); + var match$3; + if (allow_default) { + var exit = 0; + if (typeof match$2 === "string" && match$2 === "T_ASSIGN") { + token$3(env); + match$3 = [ + union(env), + true + ]; + } else { + exit = 1; + } + if (exit === 1) { + if (require_default) { + error_at(env, [ + loc, + "MissingTypeParamDefault" + ]); + } + match$3 = [ + undefined, + require_default + ]; + } + + } else { + match$3 = [ + undefined, + false + ]; + } + var param_1 = { + name: id.name, + bound: id.typeAnnotation, + variance: variance, + default: match$3[0] }; - var t$1 = [ + var param = [ loc, - t_1 + param_1 ]; - _t = t$1; + var acc$1 = { + hd: param, + tl: acc + }; + var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match$4 === "string") { + switch (match$4) { + case "T_GREATER_THAN" : + case "T_EOF" : + return List.rev(acc$1); + default: + + } + } + token$4(env, "T_COMMA"); + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_GREATER_THAN") { + return List.rev(acc$1); + } + _acc = acc$1; + _require_default = match$3[1]; continue ; }; } -function generic_type_with_identifier(env, id) { - var match = Curry._2(raw_generic_with_identifier, env, id); +function type_parameter_declaration(allow_default, env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_LESS_THAN") { + return ; + } + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + token$4(env, "T_LESS_THAN"); + var params$1 = params(env, allow_default, false, /* [] */0); + var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); + token$4(env, "T_GREATER_THAN"); return [ - match[0], + loc, { - TAG: "Generic", - _0: match[1] + params: params$1 } ]; } -function function_param_or_generic_type(env) { - var id = Curry._2(Parse.identifier, undefined, env); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - if (typeof match !== "object") { - switch (match) { - case "T_PLING" : - case "T_COLON" : - exit = 2; - break; - default: - exit = 1; - } +function union_with(env, left) { + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_OR") { + var _acc = { + hd: left, + tl: /* [] */0 + }; + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "string" && match === "T_BIT_OR") { + token$4(env, "T_BIT_OR"); + _acc = { + hd: intersection(env), + tl: acc + }; + continue ; + } + var match$1 = rev_nonempty_acc(acc); + return [ + match$1[0], + { + TAG: "Union", + _0: match$1[1] + } + ]; + }; } else { - exit = 1; - } - switch (exit) { - case 1 : - return { - TAG: "Type", - _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) - }; - case 2 : - var param = function_param_with_id(env, id); - maybe(env, "T_COMMA"); - return { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - - } -} - -function param_list_or_type(env) { - token$4(env, "T_LPAREN"); - var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); - var ret; - var exit = 0; - if (typeof token$5 !== "object") { - switch (token$5) { - case "T_IDENTIFIER" : - ret = function_param_or_generic_type(env); - break; - case "T_RPAREN" : - ret = { - TAG: "ParamList", - _0: [ - undefined, - /* [] */0 - ] - }; - break; - case "T_ELLIPSIS" : - case "T_EOF" : - ret = { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, /* [] */0) - }; - break; - default: - exit = 1; - } - } else { - exit = 1; - } - if (exit === 1) { - var match = primitive(token$5); - if (match !== undefined) { - var match$1 = Curry._2(Parser_env_Peek.token, 1, env); - var exit$1 = 0; - if (typeof match$1 !== "object") { - switch (match$1) { - case "T_PLING" : - case "T_COLON" : - exit$1 = 2; - break; - default: - ret = { - TAG: "Type", - _0: union(env) - }; - } - } else { - ret = { - TAG: "Type", - _0: union(env) - }; - } - if (exit$1 === 2) { - var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var name = match$2[0]; - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); - } - var optional = maybe(env, "T_PLING"); - token$4(env, "T_COLON"); - var typeAnnotation = union(env); - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RPAREN") { - token$4(env, "T_COMMA"); - } - var param_0 = btwn(name[0], typeAnnotation[0]); - var param_1 = { - name: name, - typeAnnotation: typeAnnotation, - optional: optional - }; - var param = [ - param_0, - param_1 - ]; - ret = { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - } - - } else { - ret = { - TAG: "Type", - _0: union(env) - }; - } - } - token$4(env, "T_RPAREN"); - return ret; -} - -function postfix(env) { - var t = primary(env); - return postfix_with(env, t); -} - -function intersection_with(env, left) { - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_AND") { - var _acc = { - hd: left, - tl: /* [] */0 - }; - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_BIT_AND") { - token$4(env, "T_BIT_AND"); - _acc = { - hd: prefix(env), - tl: acc - }; - continue ; - } - var match$1 = rev_nonempty_acc(acc); - return [ - match$1[0], - { - TAG: "Intersection", - _0: match$1[1] - } - ]; - }; - } else { - return left; + return left; } } @@ -7257,7 +7409,7 @@ function function_param_list_without_parens(env) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t !== "object") { + if (typeof t === "string") { switch (t) { case "T_RPAREN" : case "T_ELLIPSIS" : @@ -7294,117 +7446,63 @@ function function_param_list_without_parens(env) { }; } -function params(env, allow_default, _require_default, _acc) { +function intersection_with(env, left) { + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_AND") { + var _acc = { + hd: left, + tl: /* [] */0 + }; + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "string" && match === "T_BIT_AND") { + token$4(env, "T_BIT_AND"); + _acc = { + hd: prefix(env), + tl: acc + }; + continue ; + } + var match$1 = rev_nonempty_acc(acc); + return [ + match$1[0], + { + TAG: "Intersection", + _0: match$1[1] + } + ]; + }; + } else { + return left; + } +} + +function types(env, _acc) { while(true) { var acc = _acc; - var require_default = _require_default; var match = Curry._2(Parser_env_Peek.token, undefined, env); - var variance; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { - case "T_PLUS" : - token$3(env); - variance = "Plus"; - break; - case "T_MINUS" : - token$3(env); - variance = "Minus"; - break; + case "T_RBRACKET" : + case "T_EOF" : + return List.rev(acc); default: - variance = undefined; - } - } else { - variance = undefined; - } - var match$1 = Curry._2(Parse.identifier_with_type, env, "StrictParamName"); - var id = match$1[1]; - var loc = match$1[0]; - var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - var match$3; - if (allow_default) { - var exit = 0; - if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { - token$3(env); - match$3 = [ - union(env), - true - ]; - } else { - exit = 1; - } - if (exit === 1) { - if (require_default) { - error_at(env, [ - loc, - "MissingTypeParamDefault" - ]); - } - match$3 = [ - undefined, - require_default - ]; + } - - } else { - match$3 = [ - undefined, - false - ]; } - var param_1 = { - name: id.name, - bound: id.typeAnnotation, - variance: variance, - default: match$3[0] - }; - var param = [ - loc, - param_1 - ]; + var acc_0 = union(env); var acc$1 = { - hd: param, + hd: acc_0, tl: acc }; - var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$4 !== "object") { - switch (match$4) { - case "T_GREATER_THAN" : - case "T_EOF" : - return List.rev(acc$1); - default: - - } - } - token$4(env, "T_COMMA"); - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_GREATER_THAN") { - return List.rev(acc$1); + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RBRACKET") { + token$4(env, "T_COMMA"); } _acc = acc$1; - _require_default = match$3[1]; continue ; }; } -function type_parameter_declaration(allow_default, env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_LESS_THAN") { - return ; - } - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); - } - token$4(env, "T_LESS_THAN"); - var params$1 = params(env, allow_default, false, /* [] */0); - var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); - token$4(env, "T_GREATER_THAN"); - return [ - loc, - { - params: params$1 - } - ]; -} - function methodish(env, start_loc) { var typeParameters = Curry._2(type_parameter_declaration, false, env); var match = function_param_list(env); @@ -7496,7 +7594,7 @@ function indexer_property(env, start_loc, $$static) { function semicolon$1(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return error_unexpected(env); } switch (match) { @@ -7520,7 +7618,7 @@ function properties(allow_static, env, _param) { var $$static = allow_static && maybe(env, "T_STATIC"); var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LBRACKET" : var indexer = indexer_property(env, start_loc, $$static); @@ -7553,7 +7651,7 @@ function properties(allow_static, env, _param) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; var exit$1 = 0; - if ($$static && typeof match$1 !== "object" && match$1 === "T_COLON") { + if ($$static && typeof match$1 === "string" && match$1 === "T_COLON") { strict_error_at(env, [ start_loc, "StrictReservedWord" @@ -7593,7 +7691,7 @@ function properties(allow_static, env, _param) { var $$static$1 = match$2[0]; var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var property$1; - if (typeof match$3 !== "object") { + if (typeof match$3 === "string") { switch (match$3) { case "T_LPAREN" : case "T_LESS_THAN" : @@ -7659,13 +7757,13 @@ function _object(allow_staticOpt, env) { ]; } -function types(env, _acc) { +function params$1(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { - case "T_RBRACKET" : + case "T_GREATER_THAN" : case "T_EOF" : return List.rev(acc); default: @@ -7677,33 +7775,7 @@ function types(env, _acc) { hd: acc_0, tl: acc }; - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RBRACKET") { - token$4(env, "T_COMMA"); - } - _acc = acc$1; - continue ; - }; -} - -function params$1(env, _acc) { - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { - switch (match) { - case "T_GREATER_THAN" : - case "T_EOF" : - return List.rev(acc); - default: - - } - } - var acc_0 = union(env); - var acc$1 = { - hd: acc_0, - tl: acc - }; - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_GREATER_THAN") { + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_GREATER_THAN") { token$4(env, "T_COMMA"); } _acc = acc$1; @@ -7728,92 +7800,6 @@ function type_parameter_instantiation(env) { ]; } -function identifier(env, _param) { - while(true) { - var param = _param; - var qualification = param[1]; - var q_loc = param[0]; - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_PERIOD") { - return [ - q_loc, - qualification - ]; - } - token$4(env, "T_PERIOD"); - var id = Curry._2(Parse.identifier, undefined, env); - var loc = btwn(q_loc, id[0]); - var qualification$1 = { - TAG: "Qualified", - _0: [ - loc, - { - qualification: qualification, - id: id - } - ] - }; - _param = [ - loc, - qualification$1 - ]; - continue ; - }; -} - -function raw_generic_with_identifier(env, id) { - var id_0 = id[0]; - var id_1 = { - TAG: "Unqualified", - _0: id - }; - var id$1 = [ - id_0, - id_1 - ]; - var match = identifier(env, id$1); - var id_loc = match[0]; - var typeParameters = Curry._1(type_parameter_instantiation, env); - var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; - return [ - loc, - { - id: match[1], - typeParameters: typeParameters - } - ]; -} - -function union_with(env, left) { - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_OR") { - var _acc = { - hd: left, - tl: /* [] */0 - }; - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_BIT_OR") { - token$4(env, "T_BIT_OR"); - _acc = { - hd: intersection(env), - tl: acc - }; - continue ; - } - var match$1 = rev_nonempty_acc(acc); - return [ - match$1[0], - { - TAG: "Union", - _0: match$1[1] - } - ]; - }; - } else { - return left; - } -} - var _type = union; function annotation(env) { @@ -7846,7 +7832,7 @@ function annotation(env) { function annotation_opt(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_COLON") { + if (typeof match === "string" && match === "T_COLON") { return annotation(env); } @@ -8027,7 +8013,7 @@ function param_list(env, _param) { var params = param$2[0]; var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t !== "object") { + if (typeof t === "string") { switch (t) { case "T_RPAREN" : case "T_ELLIPSIS" : @@ -8142,7 +8128,7 @@ function _function(env) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; var exit = 0; - if (match && typeof match$1 !== "object") { + if (match && typeof match$1 === "string") { switch (match$1) { case "T_LPAREN" : match$2 = [ @@ -8329,7 +8315,7 @@ function variable(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_VAR" : match$1 = declarations("T_VAR", "Var", env); @@ -8369,7 +8355,7 @@ function is_tighter(a, b) { function is_lhs(param) { var tmp = param[1]; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return false; } switch (tmp.TAG) { @@ -8383,7 +8369,7 @@ function is_lhs(param) { function is_assignable_lhs(param) { var tmp = param[1]; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return false; } switch (tmp.TAG) { @@ -8400,7 +8386,7 @@ function is_assignable_lhs(param) { function assignment_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var op; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RSHIFT3_ASSIGN" : op = "RShift3Assign"; @@ -8480,7 +8466,7 @@ function conditional(env) { function peek_unary_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return ; } switch (match) { @@ -8518,7 +8504,7 @@ function unary(env) { var loc = btwn(begin_loc, argument[0]); if (op === "Delete") { var tmp = argument[1]; - if (typeof tmp === "object" && tmp.TAG === "Identifier") { + if (typeof tmp !== "string" && tmp.TAG === "Identifier") { strict_error_at(env, [ loc, "StrictDelete" @@ -8540,7 +8526,7 @@ function unary(env) { } var match = Curry._2(Parser_env_Peek.token, undefined, env); var op$1; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_INCR" : op$1 = "Increment"; @@ -8561,7 +8547,7 @@ function unary(env) { } var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var op$2; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { switch (match$1) { case "T_INCR" : op$2 = "Increment"; @@ -8585,7 +8571,7 @@ function unary(env) { ]); } var match$2 = argument$1[1]; - if (typeof match$2 === "object" && match$2.TAG === "Identifier") { + if (typeof match$2 !== "string" && match$2.TAG === "Identifier") { if (is_restricted(match$2._0[1].name)) { strict_error(env, "StrictLHSPostfix"); } @@ -8614,7 +8600,7 @@ function unary(env) { ]); } var match$3 = argument$2[1]; - if (typeof match$3 === "object" && match$3.TAG === "Identifier") { + if (typeof match$3 !== "string" && match$3.TAG === "Identifier") { if (is_restricted(match$3._0[1].name)) { strict_error(env, "StrictLHSPrefix"); } @@ -8637,7 +8623,7 @@ function left_hand_side(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var expr; var exit = 0; - if (typeof match !== "object" && match === "T_NEW") { + if (typeof match === "string" && match === "T_NEW") { expr = _new(env, (function (new_expr, _args) { return new_expr; })); @@ -8649,7 +8635,7 @@ function left_hand_side(env) { } var expr$1 = member(env, expr); var part = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof part !== "object") { + if (typeof part === "string") { if (part === "T_LPAREN") { return call(env, expr$1); } else { @@ -8666,7 +8652,7 @@ function call(env, _left) { while(true) { var left = _left; var part = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof part === "object") { + if (typeof part !== "string") { if (part.TAG === "T_TEMPLATE_PART") { return tagged_template(env, left, part._0); } else { @@ -8740,7 +8726,7 @@ function _new(env, _finish_fn) { while(true) { var finish_fn = _finish_fn; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_NEW") { + if (typeof match === "string" && match === "T_NEW") { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_NEW"); var finish_fn$p = (function(finish_fn,start_loc){ @@ -8775,17 +8761,17 @@ function _new(env, _finish_fn) { var callee = member(with_no_call(true, env), expr); var part = Curry._2(Parser_env_Peek.token, undefined, env); var callee$1; - callee$1 = typeof part !== "object" || part.TAG !== "T_TEMPLATE_PART" ? callee : tagged_template(env, callee, part._0); + callee$1 = typeof part === "string" || part.TAG !== "T_TEMPLATE_PART" ? callee : tagged_template(env, callee, part._0); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var args; - args = typeof match$1 !== "object" && match$1 === "T_LPAREN" ? Curry._1($$arguments, env) : undefined; + args = typeof match$1 === "string" && match$1 === "T_LPAREN" ? Curry._1($$arguments, env) : undefined; return Curry._2(finish_fn, callee$1, args); }; } function member(env, left) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return left; } switch (match) { @@ -8845,7 +8831,7 @@ function _function$1(env) { } else { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var id; - id = typeof match$1 !== "object" && match$1 === "T_LESS_THAN" ? undefined : Curry._2(Parse.identifier, "StrictFunctionName", env); + id = typeof match$1 === "string" && match$1 === "T_LESS_THAN" ? undefined : Curry._2(Parse.identifier, "StrictFunctionName", env); match = [ id, Curry._1(type_parameter_declaration$1, env) @@ -8923,7 +8909,7 @@ function primary$1(env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var number_type = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof number_type !== "object") { + if (typeof number_type === "string") { switch (number_type) { case "T_LCURLY" : var match = Curry._1(Parse.object_initializer, env); @@ -8939,7 +8925,7 @@ function primary$1(env) { var expression = Curry._1(assignment, env); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var ret; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { switch (match$1) { case "T_COMMA" : ret = sequence(env, { @@ -9036,7 +9022,7 @@ function primary$1(env) { var loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env); var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); var match$5; - if (typeof match$4 !== "object") { + if (typeof match$4 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -9249,7 +9235,7 @@ function sequence(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_COMMA") { + if (typeof match === "string" && match === "T_COMMA") { token$4(env, "T_COMMA"); var expr = Curry._1(assignment, env); _acc = { @@ -9278,7 +9264,7 @@ function identifier_or_reserved_keyword(env) { var lex_value = Curry._2(Parser_env_Peek.value, undefined, env); var lex_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var exit = 0; - if (typeof lex_token !== "object") { + if (typeof lex_token === "string") { switch (lex_token) { case "T_IDENTIFIER" : case "T_DECLARE" : @@ -9297,7 +9283,7 @@ function identifier_or_reserved_keyword(env) { case 1 : var err; var exit$1 = 0; - if (typeof lex_token !== "object") { + if (typeof lex_token === "string") { switch (lex_token) { case "T_FUNCTION" : case "T_IF" : @@ -9403,7 +9389,7 @@ function assignment_but_not_arrow_function(env) { ]); } var match = expr[1]; - if (typeof match === "object" && match.TAG === "Identifier") { + if (typeof match !== "string" && match.TAG === "Identifier") { if (is_restricted(match._0[1].name)) { strict_error_at(env, [ expr[0], @@ -9439,7 +9425,7 @@ function try_assignment_but_not_arrow_function(env) { var env$1 = with_error_callback(error_callback, env); var ret = assignment_but_not_arrow_function(env$1); var match = Curry._2(Parser_env_Peek.token, undefined, env$1); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_ARROW" : case "T_COLON" : @@ -9461,7 +9447,7 @@ function try_assignment_but_not_arrow_function(env) { }; } var match$1 = ret[1]; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { return ret; } if (match$1.TAG !== "Identifier") { @@ -9483,7 +9469,7 @@ function assignment(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1 = Curry._2(Parser_env_Peek.is_identifier, undefined, env); var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_YIELD" : if (env.allow_yield) { @@ -9530,11 +9516,11 @@ function assignment(env) { return assignment_but_not_arrow_function(env); } var expr = Curry._2(Parser_env_Try.to_parse, env, try_assignment_but_not_arrow_function); - if (typeof expr === "object") { + if (typeof expr !== "string") { return expr._0; } var expr$1 = Curry._2(Parser_env_Try.to_parse, env, try_arrow_function); - if (typeof expr$1 !== "object") { + if (typeof expr$1 === "string") { return assignment_but_not_arrow_function(env); } else { return expr$1._0; @@ -9560,7 +9546,7 @@ function logical_and(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return [ lloc, left @@ -9586,7 +9572,7 @@ function logical_or(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return [ lloc, left @@ -9617,7 +9603,7 @@ function logical(env) { function binary_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var ret; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_IN" : ret = env.no_in ? undefined : [ @@ -9894,7 +9880,7 @@ function binary(env) { var right_loc = btwn(start_loc, end_loc); if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LESS_THAN") { var tmp = right[1]; - if (typeof tmp === "object" && tmp.TAG === "JSXElement") { + if (typeof tmp !== "string" && tmp.TAG === "JSXElement") { error(env, "AdjacentJSXElements"); } @@ -9936,7 +9922,7 @@ function binary(env) { function argument(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return { TAG: "Expression", _0: Curry._1(assignment, env) @@ -9967,7 +9953,7 @@ function arguments$p(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RPAREN" : case "T_EOF" : @@ -10011,11 +9997,11 @@ function template_parts(env, _quasis, _expressions) { tl: expressions }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_RCURLY") { + if (typeof match === "string" && match === "T_RCURLY") { push_lex_mode(env, "TEMPLATE"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -10142,7 +10128,7 @@ function elements(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_COMMA" : token$4(env, "T_COMMA"); @@ -10207,7 +10193,7 @@ function array_initializer(env) { } function error_callback$1(param, param$1) { - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { switch (param$1) { case "StrictParamName" : case "NewlineBeforeArrow" : @@ -10276,7 +10262,7 @@ function try_arrow_function(env) { var generator = false; var env = with_in_function(true, param); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_LCURLY") { + if (typeof match === "string" && match === "T_LCURLY") { var match$1 = function_body(env, async, generator); return [ match$1[1], @@ -10325,7 +10311,7 @@ function decorator_list_helper(env, _decorators) { while(true) { var decorators = _decorators; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return decorators; } if (match !== "T_AT") { @@ -10350,7 +10336,7 @@ function decorator_list(env) { function key(env) { var number_type = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof number_type !== "object") { + if (typeof number_type === "string") { if (number_type === "T_LBRACKET") { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_LBRACKET"); @@ -10552,7 +10538,7 @@ function property$1(env) { case "get" : var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$1 = 0; - if (typeof match$2 !== "object") { + if (typeof match$2 === "string") { switch (match$2) { case "T_LPAREN" : case "T_COLON" : @@ -10572,7 +10558,7 @@ function property$1(env) { case "set" : var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$2 = 0; - if (typeof match$3 !== "object") { + if (typeof match$3 === "string") { switch (match$3) { case "T_LPAREN" : case "T_COLON" : @@ -10661,7 +10647,7 @@ function init(env, start_loc, key, async, generator) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_COMMA" : @@ -10804,7 +10790,7 @@ function check_property(env, prop_map, prop) { switch (match$1.TAG) { case "Literal" : var s = match$1._0[1].value; - if (typeof s !== "object") { + if (typeof s === "string") { key = "null"; } else { switch (s.TAG) { @@ -10916,7 +10902,7 @@ function properties$1(env, _param) { var param = _param; var acc = param[1]; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -10977,7 +10963,7 @@ function class_implements(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -11028,7 +11014,7 @@ function set$1(env, start_loc, decorators, $$static) { function init$1(env, start_loc, decorators, key, async, generator, $$static) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_SEMICOLON" : case "T_ASSIGN" : @@ -11103,7 +11089,7 @@ function init$1(env, start_loc, decorators, key, async, generator, $$static) { switch (key.TAG) { case "Literal" : var match$4 = key._0[1].value; - kind = typeof match$4 !== "object" || !(match$4.TAG === "String" && match$4._0 === "constructor") ? "Method" : "Constructor"; + kind = typeof match$4 === "string" || !(match$4.TAG === "String" && match$4._0 === "constructor") ? "Method" : "Constructor"; break; case "Identifier" : kind = key._0[1].name === "constructor" ? "Constructor" : "Method"; @@ -11143,7 +11129,7 @@ function class_element(env) { case "get" : var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match$1 === "object") { + if (typeof match$1 !== "string") { return get$1(env, start_loc, decorators, $$static); } switch (match$1) { @@ -11164,7 +11150,7 @@ function class_element(env) { case "set" : var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$1 = 0; - if (typeof match$2 === "object") { + if (typeof match$2 !== "string") { return set$1(env, start_loc, decorators, $$static); } switch (match$2) { @@ -11199,7 +11185,7 @@ function elements$1(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_SEMICOLON" : token$4(env, "T_SEMICOLON"); @@ -11301,7 +11287,7 @@ function class_expression(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LCURLY" : case "T_EXTENDS" : @@ -11345,239 +11331,54 @@ function class_expression(env) { ]; } -function declare(in_moduleOpt, env) { - var in_module = in_moduleOpt !== undefined ? in_moduleOpt : false; - if (!env.parse_options.types) { - error(env, "UnexpectedTypeDeclaration"); - } - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var match = Curry._2(Parser_env_Peek.token, 1, env); - if (typeof match !== "object") { - switch (match) { - case "T_IDENTIFIER" : - if (Curry._2(Parser_env_Peek.value, 1, env) === "module") { - token$4(env, "T_DECLARE"); - contextual(env, "module"); - if (in_module || Curry._2(Parser_env_Peek.token, undefined, env) === "T_PERIOD") { - token$4(env, "T_PERIOD"); - contextual(env, "exports"); - var type_annot = wrap(annotation, env); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : type_annot[0]; - semicolon(env); - var loc$1 = btwn(start_loc, end_loc); - return [ - loc$1, - { - TAG: "DeclareModuleExports", - _0: type_annot - } - ]; - } else { - var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); - var id; - if (typeof match$1 !== "object" || match$1.TAG !== "T_STRING") { - id = { - TAG: "Identifier", - _0: Curry._2(Parse.identifier, undefined, env) - }; - } else { - var match$2 = match$1._0; - var octal = match$2[3]; - var raw = match$2[2]; - var value = match$2[1]; - var loc$2 = match$2[0]; - if (octal) { - strict_error(env, "StrictOctalLiteral"); - } - token$4(env, { - TAG: "T_STRING", - _0: [ - loc$2, - value, - raw, - octal - ] - }); - var value$1 = { - TAG: "String", - _0: value - }; - id = { - TAG: "Literal", - _0: [ - loc$2, - { - value: value$1, - raw: raw - } - ] - }; - } - var body_start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_LCURLY"); - var match$3 = module_items(env, undefined, /* [] */0); - var module_kind = match$3[0]; - token$4(env, "T_RCURLY"); - var body_end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var body_loc = btwn(body_start_loc, body_end_loc); - var body_1 = { - body: match$3[1] - }; - var body = [ - body_loc, - body_1 - ]; - var loc$3 = btwn(start_loc, body_loc); - var kind = module_kind !== undefined ? module_kind : ({ - TAG: "CommonJS", - _0: loc$3 - }); - return [ - loc$3, - { - TAG: "DeclareModule", - _0: { - id: id, - body: body, - kind: kind - } - } - ]; - } - } - break; - case "T_FUNCTION" : - token$4(env, "T_DECLARE"); - return declare_function_statement(env, start_loc); - case "T_VAR" : - token$4(env, "T_DECLARE"); - return declare_var_statement(env, start_loc); - case "T_CLASS" : - token$4(env, "T_DECLARE"); - var match$4 = Curry._2(declare_class, env, start_loc); - return [ - match$4[0], - { - TAG: "DeclareClass", - _0: match$4[1] - } - ]; - case "T_EXPORT" : - if (in_module) { - return declare_export_declaration(in_module, env); - } - break; - case "T_INTERFACE" : - token$4(env, "T_DECLARE"); - return $$interface(env); - case "T_TYPE" : - token$4(env, "T_DECLARE"); - return type_alias(env); - case "T_ASYNC" : - token$4(env, "T_DECLARE"); - error(env, "DeclareAsync"); - token$4(env, "T_ASYNC"); - return declare_function_statement(env, start_loc); - default: - - } - } - if (in_module) { - token$4(env, "T_DECLARE"); - return declare_var_statement(env, start_loc); - } else { - return Curry._1(Parse.statement, env); - } -} - -function type_alias_helper(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAlias"); - } - token$4(env, "T_TYPE"); - push_lex_mode(env, "TYPE"); +function declare_function(env, start_loc) { + token$4(env, "T_FUNCTION"); var id = Curry._2(Parse.identifier, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - token$4(env, "T_ASSIGN"); - var right = wrap(_type, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; - semicolon(env); - pop_lex_mode(env); - return [ - btwn(start_loc, end_loc$1), - { - id: id, - typeParameters: typeParameters, - right: right - } - ]; -} - -function export_source(env) { - contextual(env, "from"); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object" && match.TAG === "T_STRING") { - var match$1 = match._0; - var octal = match$1[3]; - var raw = match$1[2]; - var value = match$1[1]; - var loc = match$1[0]; - if (octal) { - strict_error(env, "StrictOctalLiteral"); + var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration$1, env); + var match = wrap(function_param_list, env); + token$4(env, "T_COLON"); + var returnType = wrap(_type, env); + var end_loc = returnType[0]; + var loc = btwn(start_sig_loc, end_loc); + var value_1 = { + TAG: "Function", + _0: { + params: match[1], + returnType: returnType, + rest: match[0], + typeParameters: typeParameters } - token$4(env, { - TAG: "T_STRING", - _0: [ - loc, - value, - raw, - octal - ] - }); - var value$1 = { - TAG: "String", - _0: value - }; - return [ - loc, - { - value: value$1, - raw: raw - } - ]; - } - var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); - var value$2 = { - TAG: "String", - _0: raw$1 }; - var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); - var ret_1 = { - value: value$2, - raw: raw$1 + var value = [ + loc, + value_1 + ]; + var typeAnnotation = [ + loc, + value + ]; + var init = id[1]; + var id_0 = btwn(id[0], end_loc); + var id_1 = { + name: init.name, + typeAnnotation: typeAnnotation, + optional: init.optional }; - var ret = [ - ret_0, - ret_1 + var id$1 = [ + id_0, + id_1 ]; - error_unexpected(env); - return ret; -} - -function declare_var(env, start_loc) { - token$4(env, "T_VAR"); - var id = Curry._2(Parse.identifier_with_type, env, "StrictVarName"); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : id[0]; - var loc$1 = btwn(start_loc, end_loc); + var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; + var predicate = Curry._1(Parse.predicate, env); semicolon(env); + var loc$1 = btwn(start_loc, end_loc$2); return [ loc$1, { - id: id + id: id$1, + predicate: predicate } ]; } @@ -11587,7 +11388,7 @@ function export_specifiers_and_errs(env, _specifiers, _errs) { var errs = _errs; var specifiers = _specifiers; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -11653,102 +11454,310 @@ function export_specifiers_and_errs(env, _specifiers, _errs) { }; } -function declare_function(env, start_loc) { - token$4(env, "T_FUNCTION"); - var id = Curry._2(Parse.identifier, undefined, env); - var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration$1, env); - var match = wrap(function_param_list, env); - token$4(env, "T_COLON"); - var returnType = wrap(_type, env); - var end_loc = returnType[0]; - var loc = btwn(start_sig_loc, end_loc); - var value_1 = { - TAG: "Function", - _0: { - params: match[1], - returnType: returnType, - rest: match[0], - typeParameters: typeParameters - } - }; - var value = [ - loc, - value_1 - ]; - var typeAnnotation = [ - loc, - value - ]; - var init = id[1]; - var id_0 = btwn(id[0], end_loc); - var id_1 = { - name: init.name, - typeAnnotation: typeAnnotation, - optional: init.optional - }; - var id$1 = [ - id_0, - id_1 - ]; - var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; - var predicate = Curry._1(Parse.predicate, env); +function declare_var(env, start_loc) { + token$4(env, "T_VAR"); + var id = Curry._2(Parse.identifier_with_type, env, "StrictVarName"); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : id[0]; + var loc$1 = btwn(start_loc, end_loc); semicolon(env); - var loc$1 = btwn(start_loc, end_loc$2); return [ loc$1, { - id: id$1, - predicate: predicate + id: id } ]; } -function extract_ident_name(param) { - return param[1].name; -} - -function type_alias(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return Curry._1(Parse.statement, env); +function export_source(env) { + contextual(env, "from"); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "string" && match.TAG === "T_STRING") { + var match$1 = match._0; + var octal = match$1[3]; + var raw = match$1[2]; + var value = match$1[1]; + var loc = match$1[0]; + if (octal) { + strict_error(env, "StrictOctalLiteral"); + } + token$4(env, { + TAG: "T_STRING", + _0: [ + loc, + value, + raw, + octal + ] + }); + var value$1 = { + TAG: "String", + _0: value + }; + return [ + loc, + { + value: value$1, + raw: raw + } + ]; } - var match = type_alias_helper(env); - return [ - match[0], - { - TAG: "TypeAlias", - _0: match[1] - } - ]; + var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); + var value$2 = { + TAG: "String", + _0: raw$1 + }; + var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); + var ret_1 = { + value: value$2, + raw: raw$1 + }; + var ret = [ + ret_0, + ret_1 + ]; + error_unexpected(env); + return ret; } -function $$interface(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return expression(env); +function type_alias_helper(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAlias"); } - var match = Curry._1(interface_helper, env); - return [ - match[0], - { - TAG: "InterfaceDeclaration", - _0: match[1] - } - ]; -} - -function declare_var_statement(env, start_loc) { - var match = declare_var(env, start_loc); + token$4(env, "T_TYPE"); + push_lex_mode(env, "TYPE"); + var id = Curry._2(Parse.identifier, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); + token$4(env, "T_ASSIGN"); + var right = wrap(_type, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; + semicolon(env); + pop_lex_mode(env); return [ - match[0], + btwn(start_loc, end_loc$1), { - TAG: "DeclareVariable", - _0: match[1] + id: id, + typeParameters: typeParameters, + right: right } ]; } -function declare_export_declaration(allow_export_typeOpt, env) { +function declare(in_moduleOpt, env) { + var in_module = in_moduleOpt !== undefined ? in_moduleOpt : false; + if (!env.parse_options.types) { + error(env, "UnexpectedTypeDeclaration"); + } + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var match = Curry._2(Parser_env_Peek.token, 1, env); + if (typeof match === "string") { + switch (match) { + case "T_IDENTIFIER" : + if (Curry._2(Parser_env_Peek.value, 1, env) === "module") { + token$4(env, "T_DECLARE"); + contextual(env, "module"); + if (in_module || Curry._2(Parser_env_Peek.token, undefined, env) === "T_PERIOD") { + token$4(env, "T_PERIOD"); + contextual(env, "exports"); + var type_annot = wrap(annotation, env); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : type_annot[0]; + semicolon(env); + var loc$1 = btwn(start_loc, end_loc); + return [ + loc$1, + { + TAG: "DeclareModuleExports", + _0: type_annot + } + ]; + } else { + var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); + var id; + if (typeof match$1 === "string" || match$1.TAG !== "T_STRING") { + id = { + TAG: "Identifier", + _0: Curry._2(Parse.identifier, undefined, env) + }; + } else { + var match$2 = match$1._0; + var octal = match$2[3]; + var raw = match$2[2]; + var value = match$2[1]; + var loc$2 = match$2[0]; + if (octal) { + strict_error(env, "StrictOctalLiteral"); + } + token$4(env, { + TAG: "T_STRING", + _0: [ + loc$2, + value, + raw, + octal + ] + }); + var value$1 = { + TAG: "String", + _0: value + }; + id = { + TAG: "Literal", + _0: [ + loc$2, + { + value: value$1, + raw: raw + } + ] + }; + } + var body_start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_LCURLY"); + var match$3 = module_items(env, undefined, /* [] */0); + var module_kind = match$3[0]; + token$4(env, "T_RCURLY"); + var body_end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var body_loc = btwn(body_start_loc, body_end_loc); + var body_1 = { + body: match$3[1] + }; + var body = [ + body_loc, + body_1 + ]; + var loc$3 = btwn(start_loc, body_loc); + var kind = module_kind !== undefined ? module_kind : ({ + TAG: "CommonJS", + _0: loc$3 + }); + return [ + loc$3, + { + TAG: "DeclareModule", + _0: { + id: id, + body: body, + kind: kind + } + } + ]; + } + } + break; + case "T_FUNCTION" : + token$4(env, "T_DECLARE"); + return declare_function_statement(env, start_loc); + case "T_VAR" : + token$4(env, "T_DECLARE"); + return declare_var_statement(env, start_loc); + case "T_CLASS" : + token$4(env, "T_DECLARE"); + var match$4 = Curry._2(declare_class, env, start_loc); + return [ + match$4[0], + { + TAG: "DeclareClass", + _0: match$4[1] + } + ]; + case "T_EXPORT" : + if (in_module) { + return declare_export_declaration(in_module, env); + } + break; + case "T_INTERFACE" : + token$4(env, "T_DECLARE"); + return $$interface(env); + case "T_TYPE" : + token$4(env, "T_DECLARE"); + return type_alias(env); + case "T_ASYNC" : + token$4(env, "T_DECLARE"); + error(env, "DeclareAsync"); + token$4(env, "T_ASYNC"); + return declare_function_statement(env, start_loc); + default: + + } + } + if (in_module) { + token$4(env, "T_DECLARE"); + return declare_var_statement(env, start_loc); + } else { + return Curry._1(Parse.statement, env); + } +} + +function expression(env) { + var expression$1 = Curry._1(Parse.expression, env); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : expression$1[0]; + semicolon(env); + return [ + btwn(expression$1[0], end_loc), + { + TAG: "Expression", + _0: { + expression: expression$1 + } + } + ]; +} + +function $$interface(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { + return expression(env); + } + var match = Curry._1(interface_helper, env); + return [ + match[0], + { + TAG: "InterfaceDeclaration", + _0: match[1] + } + ]; +} + +function declare_var_statement(env, start_loc) { + var match = declare_var(env, start_loc); + return [ + match[0], + { + TAG: "DeclareVariable", + _0: match[1] + } + ]; +} + +function declare_function_statement(env, start_loc) { + var match = declare_function(env, start_loc); + return [ + match[0], + { + TAG: "DeclareFunction", + _0: match[1] + } + ]; +} + +function type_alias(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { + return Curry._1(Parse.statement, env); + } + var match = type_alias_helper(env); + return [ + match[0], + { + TAG: "TypeAlias", + _0: match[1] + } + ]; +} + +function declare_export_declaration(allow_export_typeOpt, env) { var allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; if (!env.parse_options.types) { error(env, "UnexpectedTypeDeclaration"); @@ -11759,14 +11768,14 @@ function declare_export_declaration(allow_export_typeOpt, env) { token$4(env$1, "T_EXPORT"); var match = Curry._2(Parser_env_Peek.token, undefined, env$1); var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_DEFAULT" : token$4(env$1, "T_DEFAULT"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$2; var exit$1 = 0; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { switch (match$1) { case "T_FUNCTION" : var fn = declare_function(env$1, start_loc); @@ -11914,7 +11923,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { switch (exit) { case 1 : var match$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); - if (typeof match$5 !== "object") { + if (typeof match$5 === "string") { switch (match$5) { case "T_INTERFACE" : error(env$1, "DeclareExportInterface"); @@ -11958,7 +11967,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { var token$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$7; var exit$2 = 0; - if (typeof token$5 !== "object") { + if (typeof token$5 === "string") { switch (token$5) { case "T_FUNCTION" : var fn$1 = declare_function(env$1, start_loc); @@ -12008,7 +12017,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { }; } if (exit$2 === 3) { - if (typeof token$5 !== "object") { + if (typeof token$5 === "string") { switch (token$5) { case "T_CONST" : error(env$1, "DeclareExportConst"); @@ -12045,31 +12054,8 @@ function declare_export_declaration(allow_export_typeOpt, env) { } } -function declare_function_statement(env, start_loc) { - var match = declare_function(env, start_loc); - return [ - match[0], - { - TAG: "DeclareFunction", - _0: match[1] - } - ]; -} - -function expression(env) { - var expression$1 = Curry._1(Parse.expression, env); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : expression$1[0]; - semicolon(env); - return [ - btwn(expression$1[0], end_loc), - { - TAG: "Expression", - _0: { - expression: expression$1 - } - } - ]; +function extract_ident_name(param) { + return param[1].name; } function supers(env, _acc) { @@ -12081,7 +12067,7 @@ function supers(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -12123,7 +12109,7 @@ function supers$1(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -12163,7 +12149,7 @@ function module_items(env, _module_kind, _acc) { var acc = _acc; var module_kind = _module_kind; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12181,7 +12167,7 @@ function module_items(env, _module_kind, _acc) { var module_kind$1; if (module_kind !== undefined) { if (module_kind.TAG === "CommonJS") { - if (typeof stmt$1 !== "object") { + if (typeof stmt$1 === "string") { module_kind$1 = module_kind; } else { switch (stmt$1.TAG) { @@ -12208,13 +12194,13 @@ function module_items(env, _module_kind, _acc) { module_kind$1 = module_kind; } } - } else if (typeof stmt$1 !== "object" || stmt$1.TAG !== "DeclareModuleExports") { + } else if (typeof stmt$1 === "string" || stmt$1.TAG !== "DeclareModuleExports") { module_kind$1 = module_kind; } else { error(env, "AmbiguousDeclareModuleKind"); module_kind$1 = module_kind; } - } else if (typeof stmt$1 !== "object") { + } else if (typeof stmt$1 === "string") { module_kind$1 = module_kind; } else { switch (stmt$1.TAG) { @@ -12364,7 +12350,7 @@ function case_list(env, _param) { var acc = param[1]; var seen_default = param[0]; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12376,7 +12362,7 @@ function case_list(env, _param) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var test; - if (typeof match$1 !== "object" && match$1 === "T_DEFAULT") { + if (typeof match$1 === "string" && match$1 === "T_DEFAULT") { if (seen_default) { error(env, "MultipleDefaultsInSwitch"); } @@ -12390,7 +12376,7 @@ function case_list(env, _param) { var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_COLON"); var term_fn = function (param) { - if (typeof param === "object") { + if (typeof param !== "string") { return false; } switch (param) { @@ -12443,7 +12429,7 @@ function var_or_const(env) { function source(env) { contextual(env, "from"); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object" && match.TAG === "T_STRING") { + if (typeof match !== "string" && match.TAG === "T_STRING") { var match$1 = match._0; var octal = match$1[3]; var raw = match$1[2]; @@ -12495,7 +12481,7 @@ function specifier_list(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12544,7 +12530,7 @@ function specifier_list(env, _acc) { function named_or_namespace_specifier(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_MULT") { + if (typeof match === "string" && match === "T_MULT") { token$4(env, "T_MULT"); contextual(env, "as"); var id = Curry._2(Parse.identifier, undefined, env); @@ -12568,7 +12554,7 @@ function named_or_namespace_specifier(env) { function from_expr(env, param) { var expr = param[1]; var loc = param[0]; - if (typeof expr === "object") { + if (typeof expr !== "string") { switch (expr.TAG) { case "Array" : var param$1 = [ @@ -12760,7 +12746,7 @@ function _object$2(restricted_error) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var prop; var exit = 0; - if (typeof match$1 !== "object" && match$1 === "T_COLON") { + if (typeof match$1 === "string" && match$1 === "T_COLON") { token$4(env, "T_COLON"); prop = [ pattern$1(env, restricted_error), @@ -12801,7 +12787,7 @@ function _object$2(restricted_error) { var pattern$3 = prop[0]; var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$4; - if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { + if (typeof match$2 === "string" && match$2 === "T_ASSIGN") { token$4(env, "T_ASSIGN"); var $$default = Curry._1(Parse.assignment, env); var loc$1 = btwn(pattern$3[0], $$default[0]); @@ -12835,7 +12821,7 @@ function _object$2(restricted_error) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12895,7 +12881,7 @@ function _array(restricted_error) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_COMMA" : token$4(env, "T_COMMA"); @@ -12933,7 +12919,7 @@ function _array(restricted_error) { var pattern$2 = pattern$1(env, restricted_error); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$3; - if (typeof match$1 !== "object" && match$1 === "T_ASSIGN") { + if (typeof match$1 === "string" && match$1 === "T_ASSIGN") { token$4(env, "T_ASSIGN"); var $$default = Curry._1(Parse.expression, env); var loc$1 = btwn(pattern$2[0], $$default[0]); @@ -12998,7 +12984,7 @@ function _array(restricted_error) { function pattern$1(env, restricted_error) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LCURLY" : return _object$2(restricted_error)(env); @@ -13079,7 +13065,7 @@ function member_expression(env, _member) { while(true) { var member = _member; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return member; } if (match !== "T_PERIOD") { @@ -13108,7 +13094,7 @@ function member_expression(env, _member) { function name(env) { var name$1 = identifier$1(env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return { TAG: "Identifier", _0: name$1 @@ -13192,7 +13178,7 @@ function attribute(env) { token$4(env, "T_ASSIGN"); var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof token$5 !== "object") { + if (typeof token$5 === "string") { if (token$5 === "T_LCURLY") { var match$2 = expression_container(env); var expression_container$1 = match$2[1]; @@ -13272,7 +13258,7 @@ function attributes(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LCURLY" : var attribute$1 = { @@ -13340,7 +13326,7 @@ function closing_element_without_lt(env, start_loc) { function child(env) { var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof token$5 !== "object") { + if (typeof token$5 === "string") { if (token$5 === "T_LCURLY") { var expression_container$1 = expression_container(env); return [ @@ -13388,7 +13374,7 @@ function element_or_closing(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_LESS_THAN"); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return { TAG: "ChildElement", _0: Curry._2(element_without_lt, env, start_loc) @@ -13413,7 +13399,7 @@ function children_and_closing(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LESS_THAN" : var closingElement = element_or_closing(env); @@ -13511,96 +13497,11 @@ function element_without_lt(env, start_loc) { ]; } -function statement_list_item(decoratorsOpt, env) { - var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; - if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { - error_on_decorators(env)(decorators); - } - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { - switch (match) { - case "T_CONST" : - return var_or_const(env); - case "T_LET" : - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_LET"); - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LPAREN") { - token$4(env, "T_LPAREN"); - var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var head = List.map((function (param) { - var match = param[1]; - return { - id: match.id, - init: match.init - }; - }), match$1[1]); - token$4(env, "T_RPAREN"); - var body = Curry._1(Parse.statement, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; - semicolon(env); - List.iter((function (param) { - return error_at(env, param); - }), match$1[2]); - return [ - btwn(start_loc, end_loc$1), - { - TAG: "Let", - _0: { - head: head, - body: body - } - } - ]; - } - var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var declaration = { - TAG: "VariableDeclaration", - _0: { - declarations: match$2[1], - kind: "Let" - } - }; - var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; - semicolon(env); - List.iter((function (param) { - return error_at(env, param); - }), match$2[2]); - return [ - btwn(start_loc, end_loc$3), - declaration - ]; - default: - - } - } - if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { - return _function(env); - } - if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { - return class_declaration$1(env, decorators); - } - if (typeof match === "object") { - return statement(env); - } - switch (match) { - case "T_INTERFACE" : - return $$interface(env); - case "T_DECLARE" : - return declare(undefined, env); - case "T_TYPE" : - return type_alias(env); - default: - return statement(env); - } -} - function statement(env) { while(true) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { switch (match) { case "T_LCURLY" : var match$1 = Curry._1(Parse.block_body, env); @@ -13693,7 +13594,7 @@ function statement(env) { var block = Curry._1(Parse.block_body, env); var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var handler; - if (typeof match$2 !== "object" && match$2 === "T_CATCH") { + if (typeof match$2 === "string" && match$2 === "T_CATCH") { var start_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_CATCH"); token$4(env, "T_LPAREN"); @@ -13723,7 +13624,7 @@ function statement(env) { } var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var finalizer; - if (typeof match$3 !== "object" && match$3 === "T_FINALLY") { + if (typeof match$3 === "string" && match$3 === "T_FINALLY") { token$4(env, "T_FINALLY"); finalizer = Curry._1(Parse.block_body, env); } else { @@ -13895,7 +13796,7 @@ function statement(env) { var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); var match$5; var exit$1 = 0; - if (typeof match$4 !== "object") { + if (typeof match$4 === "string") { switch (match$4) { case "T_SEMICOLON" : match$5 = [ @@ -13951,7 +13852,7 @@ function statement(env) { } var init = match$5[0]; var match$9 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$9 !== "object") { + if (typeof match$9 === "string") { switch (match$9) { case "T_IN" : assert_can_be_forin_or_forof(env, "InvalidLHSInForIn", init); @@ -14038,11 +13939,11 @@ function statement(env) { token$4(env, "T_SEMICOLON"); var match$10 = Curry._2(Parser_env_Peek.token, undefined, env); var test$2; - test$2 = typeof match$10 !== "object" && match$10 === "T_SEMICOLON" ? undefined : Curry._1(Parse.expression, env); + test$2 = typeof match$10 === "string" && match$10 === "T_SEMICOLON" ? undefined : Curry._1(Parse.expression, env); token$4(env, "T_SEMICOLON"); var match$11 = Curry._2(Parser_env_Peek.token, undefined, env); var update; - update = typeof match$11 !== "object" && match$11 === "T_RPAREN" ? undefined : Curry._1(Parse.expression, env); + update = typeof match$11 === "string" && match$11 === "T_RPAREN" ? undefined : Curry._1(Parse.expression, env); token$4(env, "T_RPAREN"); var body$6 = Curry._1(Parse.statement, with_in_loop(true, env)); return [ @@ -14085,7 +13986,7 @@ function statement(env) { var match$12 = Curry._2(Parser_env_Peek.token, undefined, env); var label$4 = expr$1[1]; var loc$11 = expr$1[0]; - if (typeof label$4 === "object" && label$4.TAG === "Identifier" && typeof match$12 !== "object" && match$12 === "T_COLON") { + if (typeof label$4 !== "string" && label$4.TAG === "Identifier" && typeof match$12 === "string" && match$12 === "T_COLON") { var label$5 = label$4._0; var match$13 = label$5[1]; var name$2 = match$13.name; @@ -14126,7 +14027,7 @@ function statement(env) { } ]; } - if (typeof match === "object") { + if (typeof match !== "string") { return expression(env); } switch (match) { @@ -14164,7 +14065,7 @@ function statement(env) { function module_item(env) { var decorators = decorator_list(env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object") { + if (typeof match !== "string") { return statement_list_item(decorators, env); } switch (match) { @@ -14174,7 +14075,7 @@ function module_item(env) { token$4(env$1, "T_EXPORT"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); var exit = 0; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { switch (match$1) { case "T_DEFAULT" : token$4(env$1, "T_DEFAULT"); @@ -14185,7 +14086,7 @@ function module_item(env) { var match$2 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$3; var exit$1 = 0; - if (typeof match$2 !== "object" && match$2 === "T_FUNCTION") { + if (typeof match$2 === "string" && match$2 === "T_FUNCTION") { var fn = _function(env$1); match$3 = [ fn[0], @@ -14240,7 +14141,7 @@ function module_item(env) { } var $$interface$1 = $$interface(env$1); var match$4 = $$interface$1[1]; - if (typeof match$4 !== "object") { + if (typeof match$4 === "string") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!", @@ -14283,7 +14184,7 @@ function module_item(env) { } var type_alias$1 = type_alias(env$1); var match$5 = type_alias$1[1]; - if (typeof match$5 !== "object") { + if (typeof match$5 === "string") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!", @@ -14369,7 +14270,7 @@ function module_item(env) { case 1 : var match$6 = Curry._2(Parser_env_Peek.token, undefined, env$1); var exportKind; - if (typeof match$6 !== "object" && match$6 === "T_TYPE") { + if (typeof match$6 === "string" && match$6 === "T_TYPE") { token$3(env$1); exportKind = "ExportType"; } else { @@ -14409,7 +14310,7 @@ function module_item(env) { var match$8 = stmt[1]; var loc$4 = stmt[0]; var names; - if (typeof match$8 !== "object") { + if (typeof match$8 === "string") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Unexpected export statement declaration!", @@ -14499,7 +14400,7 @@ function module_item(env) { token$4(env$2, "T_IMPORT"); var match$9 = Curry._2(Parser_env_Peek.token, undefined, env$2); var match$10; - if (typeof match$9 !== "object") { + if (typeof match$9 === "string") { switch (match$9) { case "T_TYPEOF" : if (!env$2.parse_options.types) { @@ -14538,7 +14439,7 @@ function module_item(env) { var match$12 = Curry._2(Parser_env_Peek.is_identifier, undefined, env$2); var exit$2 = 0; var exit$3 = 0; - if (typeof match$11 !== "object") { + if (typeof match$11 === "string") { if (match$11 === "T_COMMA") { exit$2 = 1; } else { @@ -14621,7 +14522,7 @@ function module_item(env) { var match$15 = Curry._2(Parser_env_Peek.value, undefined, env$2); var match$16; var exit$4 = 0; - if (type_ident !== undefined && typeof match$14 !== "object") { + if (type_ident !== undefined && typeof match$14 === "string") { switch (match$14) { case "T_IDENTIFIER" : if (match$15 === "from") { @@ -14662,7 +14563,7 @@ function module_item(env) { } var match$17 = Curry._2(Parser_env_Peek.token, undefined, env$2); var additional_specifiers; - if (typeof match$17 !== "object" && match$17 === "T_COMMA") { + if (typeof match$17 === "string" && match$17 === "T_COMMA") { token$4(env$2, "T_COMMA"); additional_specifiers = named_or_namespace_specifier(env$2); } else { @@ -14699,33 +14600,101 @@ function module_item(env) { } } -function statement_list(term_fn, env) { - var _acc = /* [] */0; - while(true) { - var acc = _acc; - var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t !== "object" && t === "T_EOF") { - return List.rev(acc); - } - if (Curry._1(term_fn, t)) { - return List.rev(acc); +function statement_list_item(decoratorsOpt, env) { + var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; + if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { + error_on_decorators(env)(decorators); + } + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "string") { + switch (match) { + case "T_CONST" : + return var_or_const(env); + case "T_LET" : + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_LET"); + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LPAREN") { + token$4(env, "T_LPAREN"); + var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var head = List.map((function (param) { + var match = param[1]; + return { + id: match.id, + init: match.init + }; + }), match$1[1]); + token$4(env, "T_RPAREN"); + var body = Curry._1(Parse.statement, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; + semicolon(env); + List.iter((function (param) { + return error_at(env, param); + }), match$1[2]); + return [ + btwn(start_loc, end_loc$1), + { + TAG: "Let", + _0: { + head: head, + body: body + } + } + ]; + } + var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var declaration = { + TAG: "VariableDeclaration", + _0: { + declarations: match$2[1], + kind: "Let" + } + }; + var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; + semicolon(env); + List.iter((function (param) { + return error_at(env, param); + }), match$2[2]); + return [ + btwn(start_loc, end_loc$3), + declaration + ]; + default: + } - _acc = { - hd: statement_list_item(undefined, env), - tl: acc - }; - continue ; - }; + } + if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { + return _function(env); + } + if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { + return class_declaration$1(env, decorators); + } + if (typeof match !== "string") { + return statement(env); + } + switch (match) { + case "T_INTERFACE" : + return $$interface(env); + case "T_DECLARE" : + return declare(undefined, env); + case "T_TYPE" : + return type_alias(env); + default: + return statement(env); + } } -function statement_list$1(_env, term_fn, item_fn, _param) { +var class_declaration$1 = class_declaration; + +function statement_list(_env, term_fn, item_fn, _param) { while(true) { var param = _param; var env = _env; var stmts = param[1]; var string_tokens = param[0]; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t !== "object" && t === "T_EOF") { + if (typeof t === "string" && t === "T_EOF") { return [ env, string_tokens, @@ -14751,7 +14720,7 @@ function statement_list$1(_env, term_fn, item_fn, _param) { tl: stmts }; var match = possible_directive[1]; - if (typeof match !== "object") { + if (typeof match === "string") { return [ env, string_tokens, @@ -14767,7 +14736,7 @@ function statement_list$1(_env, term_fn, item_fn, _param) { } var match$1 = match._0.expression; var match$2 = match$1[1]; - if (typeof match$2 !== "object") { + if (typeof match$2 === "string") { return [ env, string_tokens, @@ -14782,7 +14751,7 @@ function statement_list$1(_env, term_fn, item_fn, _param) { ]; } var str = match$2._0.value; - if (typeof str !== "object") { + if (typeof str === "string") { return [ env, string_tokens, @@ -14813,14 +14782,14 @@ function statement_list$1(_env, term_fn, item_fn, _param) { } function directives(env, term_fn, item_fn) { - var match = statement_list$1(env, term_fn, item_fn, [ + var match = statement_list(env, term_fn, item_fn, [ /* [] */0, /* [] */0 ]); var env$1 = match[0]; List.iter((function (param) { var token = param[1]; - if (typeof token === "object" && token.TAG === "T_STRING") { + if (typeof token !== "string" && token.TAG === "T_STRING") { if (token._0[3]) { return strict_error_at(env$1, [ param[0], @@ -14843,14 +14812,12 @@ function directives(env, term_fn, item_fn) { ]; } -var class_declaration$1 = class_declaration; - function module_body(term_fn, env) { var _acc = /* [] */0; while(true) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t !== "object" && t === "T_EOF") { + if (typeof t === "string" && t === "T_EOF") { return List.rev(acc); } if (Curry._1(term_fn, t)) { @@ -14864,12 +14831,60 @@ function module_body(term_fn, env) { }; } +function statement_list$1(term_fn, env) { + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var t = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof t === "string" && t === "T_EOF") { + return List.rev(acc); + } + if (Curry._1(term_fn, t)) { + return List.rev(acc); + } + _acc = { + hd: statement_list_item(undefined, env), + tl: acc + }; + continue ; + }; +} + +function statement_list_with_directives(term_fn, env) { + var match = Curry._3(directives, env, term_fn, (function (eta) { + return statement_list_item(undefined, eta); + })); + var env$1 = match[0]; + var stmts = Curry._2(statement_list$1, term_fn, env$1); + var stmts$1 = List.fold_left((function (acc, stmt) { + return { + hd: stmt, + tl: acc + }; + }), stmts, match[1]); + return [ + stmts$1, + env$1.in_strict_mode + ]; +} + +function module_body_with_directives(env, term_fn) { + var match = Curry._3(directives, env, term_fn, module_item); + var stmts = Curry._2(module_body, term_fn, match[0]); + return List.fold_left((function (acc, stmt) { + return { + hd: stmt, + tl: acc + }; + }), stmts, match[1]); +} + function identifier$2(restricted_error, env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var name = Curry._2(Parser_env_Peek.value, undefined, env); var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t !== "object" && t === "T_LET") { + if (typeof t === "string" && t === "T_LET") { if (env.in_strict_mode) { strict_error(env, "StrictReservedWord"); } else if (env.no_let) { @@ -14886,7 +14901,7 @@ function identifier$2(restricted_error, env) { if (is_strict_reserved(name)) { strict_error(env, "StrictReservedWord"); token$3(env); - } else if (typeof t !== "object") { + } else if (typeof t === "string") { switch (t) { case "T_DECLARE" : case "T_TYPE" : @@ -14918,35 +14933,6 @@ function identifier$2(restricted_error, env) { ]; } -function module_body_with_directives(env, term_fn) { - var match = Curry._3(directives, env, term_fn, module_item); - var stmts = Curry._2(module_body, term_fn, match[0]); - return List.fold_left((function (acc, stmt) { - return { - hd: stmt, - tl: acc - }; - }), stmts, match[1]); -} - -function statement_list_with_directives(term_fn, env) { - var match = Curry._3(directives, env, term_fn, (function (eta) { - return statement_list_item(undefined, eta); - })); - var env$1 = match[0]; - var stmts = Curry._2(statement_list, term_fn, env$1); - var stmts$1 = List.fold_left((function (acc, stmt) { - return { - hd: stmt, - tl: acc - }; - }), stmts, match[1]); - return [ - stmts$1, - env$1.in_strict_mode - ]; -} - function program(env) { var stmts = module_body_with_directives(env, (function (param) { return false; @@ -14965,7 +14951,7 @@ function program(env) { function expression$1(env) { var expr = Curry._1(assignment, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_COMMA") { + if (typeof match === "string" && match === "T_COMMA") { return sequence(env, { hd: expr, tl: /* [] */0 @@ -15027,7 +15013,7 @@ function block_body(env) { var term_fn = function (t) { return t === "T_RCURLY"; }; - var body = Curry._2(statement_list, term_fn, env); + var body = Curry._2(statement_list$1, term_fn, env); var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_RCURLY"); return [ @@ -15074,8 +15060,7 @@ function predicate(env) { var loc = btwn(checks_loc, rparen_loc); return [ loc, - { - TAG: "Declared", + /* Declared */{ _0: exp } ]; @@ -15181,7 +15166,7 @@ Caml_module.update_mod({ program: program, statement: statement, statement_list_item: statement_list_item, - statement_list: statement_list, + statement_list: statement_list$1, statement_list_with_directives: statement_list_with_directives, module_body: module_body, expression: expression$1, @@ -15290,7 +15275,7 @@ function parse(content, options) { var loc = function ($$location) { var match = $$location.source; var source = match !== undefined ? ( - typeof match !== "object" ? string("(global)") : string(match._0) + typeof match === "string" ? string("(global)") : string(match._0) ) : $$null; return obj([ [ @@ -15347,7 +15332,7 @@ function parse(content, options) { var _type = function (param) { var t = param[1]; var loc = param[0]; - if (typeof t !== "object") { + if (typeof t === "string") { switch (t) { case "Any" : return node("AnyTypeAnnotation", loc, []); @@ -15496,26 +15481,104 @@ function parse(content, options) { } } }; - var expression = function (param) { - var arr = param[1]; - var loc = param[0]; - if (typeof arr !== "object") { - return node("ThisExpression", loc, []); - } - switch (arr.TAG) { - case "Array" : - return node("ArrayExpression", loc, [[ - "elements", - array_of_list((function (param) { - return option(expression_or_spread, param); - }), arr._0.elements) - ]]); - case "Object" : - return node("ObjectExpression", loc, [[ - "properties", - array_of_list(object_property, arr._0.properties) - ]]); - case "Function" : + var jsx_member_expression = function (param) { + var member_expression = param[1]; + var id = member_expression._object; + var _object; + _object = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ + [ + "object", + _object + ], + [ + "property", + jsx_identifier(member_expression.property) + ] + ]); + }; + var jsx_namespaced_name = function (param) { + var namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ + [ + "namespace", + jsx_identifier(namespaced_name.namespace) + ], + [ + "name", + jsx_identifier(namespaced_name.name) + ] + ]); + }; + var jsx_identifier = function (param) { + return node("JSXIdentifier", param[0], [[ + "name", + string(param[1].name) + ]]); + }; + var jsx_element = function (param) { + var element = param[1]; + return node("JSXElement", param[0], [ + [ + "openingElement", + jsx_opening(element.openingElement) + ], + [ + "closingElement", + option(jsx_closing, element.closingElement) + ], + [ + "children", + array_of_list(jsx_child, element.children) + ] + ]); + }; + var jsx_expression_container = function (param) { + var expr = param[1].expression; + var expression$1; + expression$1 = expr.TAG === "Expression" ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 + ]]); + }; + var identifier = function (param) { + var id = param[1]; + return node("Identifier", param[0], [ + [ + "name", + string(id.name) + ], + [ + "typeAnnotation", + option(type_annotation, id.typeAnnotation) + ], + [ + "optional", + bool(id.optional) + ] + ]); + }; + var expression = function (param) { + var arr = param[1]; + var loc = param[0]; + if (typeof arr === "string") { + return node("ThisExpression", loc, []); + } + switch (arr.TAG) { + case "Array" : + return node("ArrayExpression", loc, [[ + "elements", + array_of_list((function (param) { + return option(expression_or_spread, param); + }), arr._0.elements) + ]]); + case "Object" : + return node("ObjectExpression", loc, [[ + "properties", + array_of_list(object_property, arr._0.properties) + ]]); + case "Function" : return function_expression([ loc, arr._0 @@ -15779,8 +15842,7 @@ function parse(content, options) { case "Update" : var update = arr._0; var match$4 = update.operator; - var operator$3; - operator$3 = match$4 === "Increment" ? "++" : "--"; + var operator$3 = match$4 ? "--" : "++"; return node("UpdateExpression", loc, [ [ "operator", @@ -15798,8 +15860,7 @@ function parse(content, options) { case "Logical" : var logical = arr._0; var match$5 = logical.operator; - var operator$4; - operator$4 = match$5 === "Or" ? "||" : "&&"; + var operator$4 = match$5 ? "&&" : "||"; return node("LogicalExpression", loc, [ [ "operator", @@ -16005,1011 +16066,1091 @@ function parse(content, options) { } }; - var identifier = function (param) { - var id = param[1]; - return node("Identifier", param[0], [ + var object_type_call_property = function (param) { + var callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ [ - "name", - string(id.name) + "value", + function_type(callProperty.value) ], [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) + "static", + bool(callProperty.static) + ] + ]); + }; + var object_type_property = function (param) { + var prop = param[1]; + var lit = prop.key; + var key; + switch (lit.TAG) { + case "Literal" : + key = literal(lit._0); + break; + case "Identifier" : + key = identifier(lit._0); + break; + case "Computed" : + throw { + RE_EXN_ID: "Failure", + _1: "There should not be computed object type property keys", + Error: new Error() + }; + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key + ], + [ + "value", + _type(prop.value) ], [ "optional", - bool(id.optional) + bool(prop.optional) + ], + [ + "static", + bool(prop.static) ] ]); }; - var type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); + var object_type_indexer = function (param) { + var indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ + [ + "id", + identifier(indexer.id) + ], + [ + "key", + _type(indexer.key) + ], + [ + "value", + _type(indexer.value) + ], + [ + "static", + bool(indexer.static) + ] + ]); }; - var literal = function (param) { - var lit = param[1]; - var raw = lit.raw; - var value = lit.value; - var loc = param[0]; - var value_; - if (typeof value !== "object") { - value_ = $$null; - } else { - switch (value.TAG) { - case "String" : - value_ = string(value._0); - break; - case "Boolean" : - value_ = bool(value._0); - break; - case "Number" : - value_ = number$1(value._0); - break; - case "RegExp" : - var match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - var props; - var exit = 0; - if (typeof value !== "object" || value.TAG !== "RegExp") { - exit = 1; - } else { - var match$1 = value._0; - var regex = obj([ - [ - "pattern", - string(match$1.pattern) - ], - [ - "flags", - string(match$1.flags) - ] - ]); - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ], - [ - "regex", - regex - ] - ]; - } - if (exit === 1) { - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ] - ]; - } - return node("Literal", loc, props); + var $$case = function (param) { + var c = param[1]; + return node("SwitchCase", param[0], [ + [ + "test", + option(expression, c.test) + ], + [ + "consequent", + array_of_list(statement, c.consequent) + ] + ]); }; - var pattern = function (param) { - var obj = param[1]; - var loc = param[0]; - switch (obj.TAG) { - case "Object" : - var obj$1 = obj._0; - return node("ObjectPattern", loc, [ + var variable_declaration = function (param) { + var $$var = param[1]; + var match = $$var.kind; + var kind; + switch (match) { + case "Var" : + kind = "var"; + break; + case "Let" : + kind = "let"; + break; + case "Const" : + kind = "const"; + break; + + } + return node("VariableDeclaration", param[0], [ + [ + "declarations", + array_of_list(variable_declarator, $$var.declarations) + ], + [ + "kind", + string(kind) + ] + ]); + }; + var interface_declaration = function (param) { + var i = param[1]; + return node("InterfaceDeclaration", param[0], [ + [ + "id", + identifier(i.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, i.typeParameters) + ], + [ + "body", + object_type(i.body) + ], + [ + "extends", + array_of_list(interface_extends, i.extends) + ] + ]); + }; + var statement = function (param) { + var b = param[1]; + var loc = param[0]; + if (typeof b === "string") { + if (b === "Empty") { + return node("EmptyStatement", loc, []); + } else { + return node("DebuggerStatement", loc, []); + } + } + switch (b.TAG) { + case "Block" : + return block([ + loc, + b._0 + ]); + case "Expression" : + return node("ExpressionStatement", loc, [[ + "expression", + expression(b._0.expression) + ]]); + case "If" : + var _if = b._0; + return node("IfStatement", loc, [ [ - "properties", - array_of_list(object_pattern_property, obj$1.properties) + "test", + expression(_if.test) ], [ - "typeAnnotation", - option(type_annotation, obj$1.typeAnnotation) + "consequent", + statement(_if.consequent) + ], + [ + "alternate", + option(statement, _if.alternate) ] ]); - case "Array" : - var arr = obj._0; - return node("ArrayPattern", loc, [ + case "Labeled" : + var labeled = b._0; + return node("LabeledStatement", loc, [ [ - "elements", - array_of_list((function (param) { - return option(array_pattern_element, param); - }), arr.elements) + "label", + identifier(labeled.label) ], [ - "typeAnnotation", - option(type_annotation, arr.typeAnnotation) + "body", + statement(labeled.body) ] ]); - case "Assignment" : - var match = obj._0; - return node("AssignmentPattern", loc, [ + case "Break" : + return node("BreakStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case "Continue" : + return node("ContinueStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case "With" : + var _with = b._0; + return node("WithStatement", loc, [ + [ + "object", + expression(_with._object) + ], + [ + "body", + statement(_with.body) + ] + ]); + case "TypeAlias" : + return type_alias([ + loc, + b._0 + ]); + case "Switch" : + var $$switch = b._0; + return node("SwitchStatement", loc, [ + [ + "discriminant", + expression($$switch.discriminant) + ], + [ + "cases", + array_of_list($$case, $$switch.cases) + ], + [ + "lexical", + bool($$switch.lexical) + ] + ]); + case "Return" : + return node("ReturnStatement", loc, [[ + "argument", + option(expression, b._0.argument) + ]]); + case "Throw" : + return node("ThrowStatement", loc, [[ + "argument", + expression(b._0.argument) + ]]); + case "Try" : + var _try = b._0; + return node("TryStatement", loc, [ + [ + "block", + block(_try.block) + ], + [ + "handler", + option($$catch, _try.handler) + ], + [ + "guardedHandlers", + array_of_list($$catch, _try.guardedHandlers) + ], + [ + "finalizer", + option(block, _try.finalizer) + ] + ]); + case "While" : + var _while = b._0; + return node("WhileStatement", loc, [ + [ + "test", + expression(_while.test) + ], + [ + "body", + statement(_while.body) + ] + ]); + case "DoWhile" : + var dowhile = b._0; + return node("DoWhileStatement", loc, [ + [ + "body", + statement(dowhile.body) + ], + [ + "test", + expression(dowhile.test) + ] + ]); + case "For" : + var _for = b._0; + var init = function (init$1) { + if (init$1.TAG === "InitDeclaration") { + return variable_declaration(init$1._0); + } else { + return expression(init$1._0); + } + }; + return node("ForStatement", loc, [ + [ + "init", + option(init, _for.init) + ], + [ + "test", + option(expression, _for.test) + ], + [ + "update", + option(expression, _for.update) + ], + [ + "body", + statement(_for.body) + ] + ]); + case "ForIn" : + var forin = b._0; + var left = forin.left; + var left$1; + left$1 = left.TAG === "LeftDeclaration" ? variable_declaration(left._0) : expression(left._0); + return node("ForInStatement", loc, [ [ "left", - pattern(match.left) + left$1 ], [ "right", - expression(match.right) + expression(forin.right) + ], + [ + "body", + statement(forin.body) + ], + [ + "each", + bool(forin.each) ] ]); - case "Identifier" : - return identifier(obj._0); - case "Expression" : - return expression(obj._0); - - } - }; - var object_pattern_property = function (param) { - if (param.TAG === "Property") { - var match = param._0; - var prop = match[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG) { - case "Literal" : - match$1 = [ - literal(lit._0), - false - ]; - break; - case "Identifier" : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case "Computed" : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - return node("PropertyPattern", match[0], [ - [ - "key", - match$1[0] - ], - [ - "pattern", - pattern(prop.pattern) - ], - [ - "computed", - bool(match$1[1]) - ], - [ - "shorthand", - bool(prop.shorthand) - ] - ]); - } - var match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ - "argument", - pattern(match$2[1].argument) - ]]); - }; - var array_pattern_element = function (p) { - if (p.TAG === "Element") { - return pattern(p._0); - } - var match = p._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); - }; - var object_property = function (param) { - if (param.TAG === "Property") { - var match = param._0; - var prop = match[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG) { - case "Literal" : - match$1 = [ - literal(lit._0), - false - ]; - break; - case "Identifier" : - match$1 = [ - identifier(lit._0), - false + case "ForOf" : + var forof = b._0; + var left$2 = forof.left; + var left$3; + left$3 = left$2.TAG === "LeftDeclaration" ? variable_declaration(left$2._0) : expression(left$2._0); + return node("ForOfStatement", loc, [ + [ + "left", + left$3 + ], + [ + "right", + expression(forof.right) + ], + [ + "body", + statement(forof.body) + ] + ]); + case "Let" : + var _let = b._0; + return node("LetStatement", loc, [ + [ + "head", + array_of_list(let_assignment, _let.head) + ], + [ + "body", + statement(_let.body) + ] + ]); + case "FunctionDeclaration" : + var fn = b._0; + var id = fn.id; + var match = id !== undefined ? [ + "FunctionDeclaration", + identifier(id) + ] : [ + "FunctionExpression", + $$null ]; - break; - case "Computed" : - match$1 = [ - expression(lit._0), - true + var b$1 = fn.body; + var body; + body = b$1.TAG === "BodyBlock" ? block(b$1._0) : expression(b$1._0); + return node(match[0], loc, [ + [ + "id", + match[1] + ], + [ + "params", + array_of_list(pattern, fn.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), fn.defaults) + ], + [ + "rest", + option(identifier, fn.rest) + ], + [ + "body", + body + ], + [ + "async", + bool(fn.async) + ], + [ + "generator", + bool(fn.generator) + ], + [ + "expression", + bool(fn.expression) + ], + [ + "returnType", + option(type_annotation, fn.returnType) + ], + [ + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) + ] + ]); + case "VariableDeclaration" : + return variable_declaration([ + loc, + b._0 + ]); + case "ClassDeclaration" : + var param$1 = [ + loc, + b._0 + ]; + var c = param$1[1]; + var id$1 = c.id; + var match$1 = id$1 !== undefined ? [ + "ClassDeclaration", + identifier(id$1) + ] : [ + "ClassExpression", + $$null ]; - break; - - } - var match$2 = prop.kind; - var kind; - switch (match$2) { - case "Init" : - kind = "init"; - break; - case "Get" : - kind = "get"; - break; - case "Set" : - kind = "set"; - break; - - } - return node("Property", match[0], [ - [ - "key", - match$1[0] - ], - [ - "value", - expression(prop.value) - ], - [ - "kind", - string(kind) - ], - [ - "method", - bool(prop._method) - ], - [ - "shorthand", - bool(prop.shorthand) - ], - [ - "computed", - bool(match$1[1]) - ] - ]); - } - var match$3 = param._0; - return node("SpreadProperty", match$3[0], [[ - "argument", - expression(match$3[1].argument) - ]]); - }; - var let_assignment = function (assignment) { - return obj([ - [ - "id", - pattern(assignment.id) - ], - [ - "init", - option(expression, assignment.init) - ] - ]); - }; - var expression_or_spread = function (expr) { - if (expr.TAG === "Expression") { - return expression(expr._0); - } - var match = expr._0; - return node("SpreadElement", match[0], [[ - "argument", - expression(match[1].argument) - ]]); - }; - var template_literal = function (param) { - var value = param[1]; - return node("TemplateLiteral", param[0], [ - [ - "quasis", - array_of_list(template_element, value.quasis) - ], - [ - "expressions", - array_of_list(expression, value.expressions) - ] - ]); - }; - var block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) - ]]); - }; - var function_expression = function (param) { - var _function = param[1]; - var b = _function.body; - var body; - body = b.TAG === "BodyBlock" ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ - [ - "id", - option(identifier, _function.id) - ], - [ - "params", - array_of_list(pattern, _function.params) - ], - [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) - ], - [ - "rest", - option(identifier, _function.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(_function.async) - ], - [ - "generator", - bool(_function.generator) - ], - [ - "expression", - bool(_function.expression) - ], - [ - "returnType", - option(type_annotation, _function.returnType) - ], - [ - "typeParameters", - option(type_parameter_declaration, _function.typeParameters) - ] - ]); - }; - var jsx_element = function (param) { - var element = param[1]; - return node("JSXElement", param[0], [ - [ - "openingElement", - jsx_opening(element.openingElement) - ], - [ - "closingElement", - option(jsx_closing, element.closingElement) - ], - [ - "children", - array_of_list(jsx_child, element.children) - ] - ]); - }; - var comprehension_block = function (param) { - var b = param[1]; - return node("ComprehensionBlock", param[0], [ - [ - "left", - pattern(b.left) - ], - [ - "right", - expression(b.right) - ], - [ - "each", - bool(b.each) - ] - ]); - }; - var type_parameter_declaration = function (param) { - return node("TypeParameterDeclaration", param[0], [[ - "params", - array_of_list(type_param, param[1].params) - ]]); - }; - var variable_declarator = function (param) { - var declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) - ], - [ - "init", - option(expression, declarator.init) - ] - ]); - }; - var export_specifier = function (param) { - var specifier = param[1]; - return node("ExportSpecifier", param[0], [ - [ - "id", - identifier(specifier.id) - ], - [ - "name", - option(identifier, specifier.name) - ] - ]); - }; - var generic_type_qualified_identifier = function (param) { - var q = param[1]; - var id = q.qualification; - var qualification; - qualification = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("QualifiedTypeIdentifier", param[0], [ - [ - "qualification", - qualification - ], - [ - "id", - identifier(q.id) - ] - ]); - }; - var type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); - }; - var statement = function (param) { - var b = param[1]; - var loc = param[0]; - if (typeof b !== "object") { - if (b === "Empty") { - return node("EmptyStatement", loc, []); - } else { - return node("DebuggerStatement", loc, []); - } - } - switch (b.TAG) { - case "Block" : - return block([ - loc, - b._0 - ]); - case "Expression" : - return node("ExpressionStatement", loc, [[ - "expression", - expression(b._0.expression) - ]]); - case "If" : - var _if = b._0; - return node("IfStatement", loc, [ + return node(match$1[0], param$1[0], [ [ - "test", - expression(_if.test) + "id", + match$1[1] ], [ - "consequent", - statement(_if.consequent) + "body", + class_body(c.body) ], [ - "alternate", - option(statement, _if.alternate) - ] - ]); - case "Labeled" : - var labeled = b._0; - return node("LabeledStatement", loc, [ + "superClass", + option(expression, c.superClass) + ], [ - "label", - identifier(labeled.label) + "typeParameters", + option(type_parameter_declaration, c.typeParameters) ], [ - "body", - statement(labeled.body) - ] - ]); - case "Break" : - return node("BreakStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case "Continue" : - return node("ContinueStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case "With" : - var _with = b._0; - return node("WithStatement", loc, [ + "superTypeParameters", + option(type_parameter_instantiation, c.superTypeParameters) + ], [ - "object", - expression(_with._object) + "implements", + array_of_list(class_implements, c.implements) ], [ - "body", - statement(_with.body) + "decorators", + array_of_list(expression, c.classDecorators) ] ]); - case "TypeAlias" : - return type_alias([ + case "InterfaceDeclaration" : + return interface_declaration([ loc, b._0 ]); - case "Switch" : - var $$switch = b._0; - return node("SwitchStatement", loc, [ - [ - "discriminant", - expression($$switch.discriminant) - ], - [ - "cases", - array_of_list($$case, $$switch.cases) - ], - [ - "lexical", - bool($$switch.lexical) - ] - ]); - case "Return" : - return node("ReturnStatement", loc, [[ - "argument", - option(expression, b._0.argument) - ]]); - case "Throw" : - return node("ThrowStatement", loc, [[ - "argument", - expression(b._0.argument) - ]]); - case "Try" : - var _try = b._0; - return node("TryStatement", loc, [ - [ - "block", - block(_try.block) - ], - [ - "handler", - option($$catch, _try.handler) - ], - [ - "guardedHandlers", - array_of_list($$catch, _try.guardedHandlers) - ], - [ - "finalizer", - option(block, _try.finalizer) - ] + case "DeclareVariable" : + return declare_variable([ + loc, + b._0 ]); - case "While" : - var _while = b._0; - return node("WhileStatement", loc, [ + case "DeclareFunction" : + return declare_function([ + loc, + b._0 + ]); + case "DeclareClass" : + return declare_class([ + loc, + b._0 + ]); + case "DeclareModule" : + var m = b._0; + var lit = m.id; + var id$2; + id$2 = lit.TAG === "Identifier" ? identifier(lit._0) : literal(lit._0); + var match$2 = m.kind; + var tmp; + tmp = match$2.TAG === "CommonJS" ? string("CommonJS") : string("ES"); + return node("DeclareModule", loc, [ [ - "test", - expression(_while.test) + "id", + id$2 ], [ "body", - statement(_while.body) - ] - ]); - case "DoWhile" : - var dowhile = b._0; - return node("DoWhileStatement", loc, [ - [ - "body", - statement(dowhile.body) + block(m.body) ], [ - "test", - expression(dowhile.test) + "kind", + tmp ] ]); - case "For" : - var _for = b._0; - var init = function (init$1) { - if (init$1.TAG === "InitDeclaration") { - return variable_declaration(init$1._0); - } else { - return expression(init$1._0); + case "DeclareModuleExports" : + return node("DeclareModuleExports", loc, [[ + "typeAnnotation", + type_annotation(b._0) + ]]); + case "DeclareExportDeclaration" : + var $$export = b._0; + var match$3 = $$export.declaration; + var declaration; + if (match$3 !== undefined) { + switch (match$3.TAG) { + case "Variable" : + declaration = declare_variable(match$3._0); + break; + case "Function" : + declaration = declare_function(match$3._0); + break; + case "Class" : + declaration = declare_class(match$3._0); + break; + case "DefaultType" : + declaration = _type(match$3._0); + break; + case "NamedType" : + declaration = type_alias(match$3._0); + break; + case "Interface" : + declaration = interface_declaration(match$3._0); + break; + } - }; - return node("ForStatement", loc, [ + } else { + declaration = $$null; + } + return node("DeclareExportDeclaration", loc, [ [ - "init", - option(init, _for.init) + "default", + bool($$export.default) ], [ - "test", - option(expression, _for.test) + "declaration", + declaration ], [ - "update", - option(expression, _for.update) + "specifiers", + export_specifiers($$export.specifiers) ], [ - "body", - statement(_for.body) + "source", + option(literal, $$export.source) ] ]); - case "ForIn" : - var forin = b._0; - var left = forin.left; - var left$1; - left$1 = left.TAG === "LeftDeclaration" ? variable_declaration(left._0) : expression(left._0); - return node("ForInStatement", loc, [ + case "ExportDeclaration" : + var $$export$1 = b._0; + var match$4 = $$export$1.declaration; + var declaration$1 = match$4 !== undefined ? ( + match$4.TAG === "Declaration" ? statement(match$4._0) : expression(match$4._0) + ) : $$null; + return node("ExportDeclaration", loc, [ [ - "left", - left$1 + "default", + bool($$export$1.default) ], [ - "right", - expression(forin.right) + "declaration", + declaration$1 ], [ - "body", - statement(forin.body) + "specifiers", + export_specifiers($$export$1.specifiers) ], [ - "each", - bool(forin.each) + "source", + option(literal, $$export$1.source) + ], + [ + "exportKind", + string($$export$1.exportKind ? "value" : "type") ] ]); - case "ForOf" : - var forof = b._0; - var left$2 = forof.left; - var left$3; - left$3 = left$2.TAG === "LeftDeclaration" ? variable_declaration(left$2._0) : expression(left$2._0); - return node("ForOfStatement", loc, [ + case "ImportDeclaration" : + var $$import = b._0; + var specifiers = List.map((function (id) { + switch (id.TAG) { + case "ImportNamedSpecifier" : + var match = id._0; + var local_id = match.local; + var remote_id = match.remote; + var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; + return node("ImportSpecifier", span_loc, [ + [ + "id", + identifier(remote_id) + ], + [ + "name", + option(identifier, local_id) + ] + ]); + case "ImportDefaultSpecifier" : + var id$1 = id._0; + return node("ImportDefaultSpecifier", id$1[0], [[ + "id", + identifier(id$1) + ]]); + case "ImportNamespaceSpecifier" : + var param = id._0; + return node("ImportNamespaceSpecifier", param[0], [[ + "id", + identifier(param[1]) + ]]); + + } + }), $$import.specifiers); + var match$5 = $$import.importKind; + var import_kind; + switch (match$5) { + case "ImportType" : + import_kind = "type"; + break; + case "ImportTypeof" : + import_kind = "typeof"; + break; + case "ImportValue" : + import_kind = "value"; + break; + + } + return node("ImportDeclaration", loc, [ [ - "left", - left$3 + "specifiers", + array($$Array.of_list(specifiers)) ], [ - "right", - expression(forof.right) + "source", + literal($$import.source) ], [ - "body", - statement(forof.body) + "importKind", + string(import_kind) ] ]); - case "Let" : - var _let = b._0; - return node("LetStatement", loc, [ + + } + }; + var pattern = function (param) { + var obj = param[1]; + var loc = param[0]; + switch (obj.TAG) { + case "Object" : + var obj$1 = obj._0; + return node("ObjectPattern", loc, [ [ - "head", - array_of_list(let_assignment, _let.head) + "properties", + array_of_list(object_pattern_property, obj$1.properties) ], [ - "body", - statement(_let.body) + "typeAnnotation", + option(type_annotation, obj$1.typeAnnotation) ] ]); - case "FunctionDeclaration" : - var fn = b._0; - var id = fn.id; - var match = id !== undefined ? [ - "FunctionDeclaration", - identifier(id) - ] : [ - "FunctionExpression", - $$null - ]; - var b$1 = fn.body; - var body; - body = b$1.TAG === "BodyBlock" ? block(b$1._0) : expression(b$1._0); - return node(match[0], loc, [ - [ - "id", - match[1] - ], - [ - "params", - array_of_list(pattern, fn.params) - ], + case "Array" : + var arr = obj._0; + return node("ArrayPattern", loc, [ [ - "defaults", + "elements", array_of_list((function (param) { - return option(expression, param); - }), fn.defaults) - ], - [ - "rest", - option(identifier, fn.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(fn.async) - ], - [ - "generator", - bool(fn.generator) + return option(array_pattern_element, param); + }), arr.elements) ], [ - "expression", - bool(fn.expression) - ], + "typeAnnotation", + option(type_annotation, arr.typeAnnotation) + ] + ]); + case "Assignment" : + var match = obj._0; + return node("AssignmentPattern", loc, [ [ - "returnType", - option(type_annotation, fn.returnType) + "left", + pattern(match.left) ], [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) + "right", + expression(match.right) ] ]); - case "VariableDeclaration" : - return variable_declaration([ + case "Identifier" : + return identifier(obj._0); + case "Expression" : + return expression(obj._0); + + } + }; + var declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var export_specifiers = function (param) { + if (param !== undefined) { + if (param.TAG === "ExportSpecifiers") { + return array_of_list(export_specifier, param._0); + } else { + return array([node("ExportBatchSpecifier", param._0, [[ + "name", + option(identifier, param._1) + ]])]); + } + } else { + return array([]); + } + }; + var type_alias = function (param) { + var alias = param[1]; + return node("TypeAlias", param[0], [ + [ + "id", + identifier(alias.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, alias.typeParameters) + ], + [ + "right", + _type(alias.right) + ] + ]); + }; + var let_assignment = function (assignment) { + return obj([ + [ + "id", + pattern(assignment.id) + ], + [ + "init", + option(expression, assignment.init) + ] + ]); + }; + var block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) + ]]); + }; + var $$catch = function (param) { + var c = param[1]; + return node("CatchClause", param[0], [ + [ + "param", + pattern(c.param) + ], + [ + "guard", + option(expression, c.guard) + ], + [ + "body", + block(c.body) + ] + ]); + }; + var literal = function (param) { + var lit = param[1]; + var raw = lit.raw; + var value = lit.value; + var loc = param[0]; + var value_; + if (typeof value === "string") { + value_ = $$null; + } else { + switch (value.TAG) { + case "String" : + value_ = string(value._0); + break; + case "Boolean" : + value_ = bool(value._0); + break; + case "Number" : + value_ = number$1(value._0); + break; + case "RegExp" : + var match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } + } + var props; + var exit = 0; + if (typeof value === "string" || value.TAG !== "RegExp") { + exit = 1; + } else { + var match$1 = value._0; + var regex = obj([ + [ + "pattern", + string(match$1.pattern) + ], + [ + "flags", + string(match$1.flags) + ] + ]); + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ], + [ + "regex", + regex + ] + ]; + } + if (exit === 1) { + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ] + ]; + } + return node("Literal", loc, props); + }; + var declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var declare_class = function (param) { + var d = param[1]; + return node("DeclareClass", param[0], [ + [ + "id", + identifier(d.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, d.typeParameters) + ], + [ + "body", + object_type(d.body) + ], + [ + "extends", + array_of_list(interface_extends, d.extends) + ] + ]); + }; + var type_parameter_declaration = function (param) { + return node("TypeParameterDeclaration", param[0], [[ + "params", + array_of_list(type_param, param[1].params) + ]]); + }; + var type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; + var export_specifier = function (param) { + var specifier = param[1]; + return node("ExportSpecifier", param[0], [ + [ + "id", + identifier(specifier.id) + ], + [ + "name", + option(identifier, specifier.name) + ] + ]); + }; + var type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) + ]]); + }; + var class_implements = function (param) { + var $$implements = param[1]; + return node("ClassImplements", param[0], [ + [ + "id", + identifier($$implements.id) + ], + [ + "typeParameters", + option(type_parameter_instantiation, $$implements.typeParameters) + ] + ]); + }; + var class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); + }; + var jsx_opening_attribute = function (attribute) { + if (attribute.TAG === "Attribute") { + var param = attribute._0; + var attribute$1 = param[1]; + var id = attribute$1.name; + var name; + name = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute$1.value) + ] + ]); + } else { + var param$1 = attribute._0; + return node("JSXSpreadAttribute", param$1[0], [[ + "argument", + expression(param$1[1].argument) + ]]); + } + }; + var jsx_name = function (id) { + switch (id.TAG) { + case "Identifier" : + return jsx_identifier(id._0); + case "NamespacedName" : + return jsx_namespaced_name(id._0); + case "MemberExpression" : + return jsx_member_expression(id._0); + + } + }; + var jsx_opening = function (param) { + var opening = param[1]; + return node("JSXOpeningElement", param[0], [ + [ + "name", + jsx_name(opening.name) + ], + [ + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) + ], + [ + "selfClosing", + bool(opening.selfClosing) + ] + ]); + }; + var jsx_child = function (param) { + var element = param[1]; + var loc = param[0]; + switch (element.TAG) { + case "Element" : + return jsx_element([ + loc, + element._0 + ]); + case "ExpressionContainer" : + return jsx_expression_container([ loc, - b._0 + element._0 ]); - case "ClassDeclaration" : + case "Text" : var param$1 = [ loc, - b._0 + element._0 ]; - var c = param$1[1]; - var id$1 = c.id; - var match$1 = id$1 !== undefined ? [ - "ClassDeclaration", - identifier(id$1) - ] : [ - "ClassExpression", - $$null - ]; - return node(match$1[0], param$1[0], [ - [ - "id", - match$1[1] - ], - [ - "body", - class_body(c.body) - ], - [ - "superClass", - option(expression, c.superClass) - ], - [ - "typeParameters", - option(type_parameter_declaration, c.typeParameters) - ], - [ - "superTypeParameters", - option(type_parameter_instantiation, c.superTypeParameters) - ], - [ - "implements", - array_of_list(class_implements, c.implements) - ], - [ - "decorators", - array_of_list(expression, c.classDecorators) - ] - ]); - case "InterfaceDeclaration" : - return interface_declaration([ - loc, - b._0 - ]); - case "DeclareVariable" : - return declare_variable([ - loc, - b._0 - ]); - case "DeclareFunction" : - return declare_function([ - loc, - b._0 - ]); - case "DeclareClass" : - return declare_class([ - loc, - b._0 - ]); - case "DeclareModule" : - var m = b._0; - var lit = m.id; - var id$2; - id$2 = lit.TAG === "Identifier" ? identifier(lit._0) : literal(lit._0); - var match$2 = m.kind; - var tmp; - tmp = match$2.TAG === "CommonJS" ? string("CommonJS") : string("ES"); - return node("DeclareModule", loc, [ - [ - "id", - id$2 - ], - [ - "body", - block(m.body) - ], - [ - "kind", - tmp - ] - ]); - case "DeclareModuleExports" : - return node("DeclareModuleExports", loc, [[ - "typeAnnotation", - type_annotation(b._0) - ]]); - case "DeclareExportDeclaration" : - var $$export = b._0; - var match$3 = $$export.declaration; - var declaration; - if (match$3 !== undefined) { - switch (match$3.TAG) { - case "Variable" : - declaration = declare_variable(match$3._0); - break; - case "Function" : - declaration = declare_function(match$3._0); - break; - case "Class" : - declaration = declare_class(match$3._0); - break; - case "DefaultType" : - declaration = _type(match$3._0); - break; - case "NamedType" : - declaration = type_alias(match$3._0); - break; - case "Interface" : - declaration = interface_declaration(match$3._0); - break; - - } - } else { - declaration = $$null; - } - return node("DeclareExportDeclaration", loc, [ - [ - "default", - bool($$export.default) - ], - [ - "declaration", - declaration - ], - [ - "specifiers", - export_specifiers($$export.specifiers) - ], - [ - "source", - option(literal, $$export.source) - ] - ]); - case "ExportDeclaration" : - var $$export$1 = b._0; - var match$4 = $$export$1.declaration; - var declaration$1 = match$4 !== undefined ? ( - match$4.TAG === "Declaration" ? statement(match$4._0) : expression(match$4._0) - ) : $$null; - return node("ExportDeclaration", loc, [ - [ - "default", - bool($$export$1.default) - ], - [ - "declaration", - declaration$1 - ], - [ - "specifiers", - export_specifiers($$export$1.specifiers) - ], - [ - "source", - option(literal, $$export$1.source) - ], - [ - "exportKind", - string(export_kind($$export$1.exportKind)) - ] - ]); - case "ImportDeclaration" : - var $$import = b._0; - var specifiers = List.map((function (id) { - switch (id.TAG) { - case "ImportNamedSpecifier" : - var match = id._0; - var local_id = match.local; - var remote_id = match.remote; - var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; - return node("ImportSpecifier", span_loc, [ - [ - "id", - identifier(remote_id) - ], - [ - "name", - option(identifier, local_id) - ] - ]); - case "ImportDefaultSpecifier" : - var id$1 = id._0; - return node("ImportDefaultSpecifier", id$1[0], [[ - "id", - identifier(id$1) - ]]); - case "ImportNamespaceSpecifier" : - var param = id._0; - return node("ImportNamespaceSpecifier", param[0], [[ - "id", - identifier(param[1]) - ]]); - - } - }), $$import.specifiers); - var match$5 = $$import.importKind; - var import_kind; - switch (match$5) { - case "ImportType" : - import_kind = "type"; - break; - case "ImportTypeof" : - import_kind = "typeof"; - break; - case "ImportValue" : - import_kind = "value"; - break; - - } - return node("ImportDeclaration", loc, [ - [ - "specifiers", - array($$Array.of_list(specifiers)) - ], - [ - "source", - literal($$import.source) + var text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) ], [ - "importKind", - string(import_kind) + "raw", + string(text.raw) ] ]); } }; - var jsx_expression_container = function (param) { - var expr = param[1].expression; - var expression$1; - expression$1 = expr.TAG === "Expression" ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 + var jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) ]]); }; - var class_implements = function (param) { - var $$implements = param[1]; - return node("ClassImplements", param[0], [ + var generic_type_qualified_identifier = function (param) { + var q = param[1]; + var id = q.qualification; + var qualification; + qualification = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ + [ + "qualification", + qualification + ], [ "id", - identifier($$implements.id) + identifier(q.id) + ] + ]); + }; + var object_type = function (param) { + var o = param[1]; + return node("ObjectTypeAnnotation", param[0], [ + [ + "properties", + array_of_list(object_type_property, o.properties) + ], + [ + "indexers", + array_of_list(object_type_indexer, o.indexers) + ], + [ + "callProperties", + array_of_list(object_type_call_property, o.callProperties) + ] + ]); + }; + var interface_extends = function (param) { + var g = param[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ + [ + "id", + id$1 ], [ "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + option(type_parameter_instantiation, g.typeParameters) ] ]); }; - var class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) - ]]); + var template_element = function (param) { + var element = param[1]; + var value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ + [ + "value", + value + ], + [ + "tail", + bool(element.tail) + ] + ]); }; var function_type = function (param) { var fn = param[1]; @@ -17032,205 +17173,177 @@ function parse(content, options) { ] ]); }; - var object_type = function (param) { - var o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ + var object_property = function (param) { + if (param.TAG === "Property") { + var match = param._0; + var prop = match[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG) { + case "Literal" : + match$1 = [ + literal(lit._0), + false + ]; + break; + case "Identifier" : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case "Computed" : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + var match$2 = prop.kind; + var kind; + switch (match$2) { + case "Init" : + kind = "init"; + break; + case "Get" : + kind = "get"; + break; + case "Set" : + kind = "set"; + break; + + } + return node("Property", match[0], [ + [ + "key", + match$1[0] + ], + [ + "value", + expression(prop.value) + ], + [ + "kind", + string(kind) + ], + [ + "method", + bool(prop._method) + ], + [ + "shorthand", + bool(prop.shorthand) + ], + [ + "computed", + bool(match$1[1]) + ] + ]); + } + var match$3 = param._0; + return node("SpreadProperty", match$3[0], [[ + "argument", + expression(match$3[1].argument) + ]]); + }; + var comprehension_block = function (param) { + var b = param[1]; + return node("ComprehensionBlock", param[0], [ [ - "properties", - array_of_list(object_type_property, o.properties) + "left", + pattern(b.left) ], [ - "indexers", - array_of_list(object_type_indexer, o.indexers) + "right", + expression(b.right) ], [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) + "each", + bool(b.each) ] ]); }; - var jsx_identifier = function (param) { - return node("JSXIdentifier", param[0], [[ - "name", - string(param[1].name) + var expression_or_spread = function (expr) { + if (expr.TAG === "Expression") { + return expression(expr._0); + } + var match = expr._0; + return node("SpreadElement", match[0], [[ + "argument", + expression(match[1].argument) ]]); }; - var object_type_call_property = function (param) { - var callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ - [ - "value", - function_type(callProperty.value) - ], - [ - "static", - bool(callProperty.static) - ] - ]); - }; - var object_type_property = function (param) { - var prop = param[1]; - var lit = prop.key; - var key; - switch (lit.TAG) { - case "Literal" : - key = literal(lit._0); - break; - case "Identifier" : - key = identifier(lit._0); - break; - case "Computed" : - throw { - RE_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; - - } - return node("ObjectTypeProperty", param[0], [ - [ - "key", - key - ], + var function_expression = function (param) { + var _function = param[1]; + var b = _function.body; + var body; + body = b.TAG === "BodyBlock" ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ [ - "value", - _type(prop.value) + "id", + option(identifier, _function.id) ], [ - "optional", - bool(prop.optional) + "params", + array_of_list(pattern, _function.params) ], [ - "static", - bool(prop.static) - ] - ]); - }; - var object_type_indexer = function (param) { - var indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), _function.defaults) + ], [ - "id", - identifier(indexer.id) + "rest", + option(identifier, _function.rest) ], [ - "key", - _type(indexer.key) + "body", + body ], [ - "value", - _type(indexer.value) + "async", + bool(_function.async) ], [ - "static", - bool(indexer.static) - ] - ]); - }; - var jsx_opening = function (param) { - var opening = param[1]; - return node("JSXOpeningElement", param[0], [ + "generator", + bool(_function.generator) + ], [ - "name", - jsx_name(opening.name) + "expression", + bool(_function.expression) ], [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) + "returnType", + option(type_annotation, _function.returnType) ], [ - "selfClosing", - bool(opening.selfClosing) + "typeParameters", + option(type_parameter_declaration, _function.typeParameters) ] ]); }; - var jsx_child = function (param) { - var element = param[1]; - var loc = param[0]; - switch (element.TAG) { - case "Element" : - return jsx_element([ - loc, - element._0 - ]); - case "ExpressionContainer" : - return jsx_expression_container([ - loc, - element._0 - ]); - case "Text" : - var param$1 = [ - loc, - element._0 - ]; - var text = param$1[1]; - return node("JSXText", param$1[0], [ - [ - "value", - string(text.value) - ], - [ - "raw", - string(text.raw) - ] - ]); - - } - }; - var jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ - "name", - jsx_name(param[1].name) - ]]); - }; - var comment = function (param) { - var c = param[1]; - var match; - match = c.TAG === "Block" ? [ - "Block", - c._0 - ] : [ - "Line", - c._0 - ]; - return node(match[0], param[0], [[ - "value", - string(match[1]) - ]]); - }; - var jsx_namespaced_name = function (param) { - var namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ + var template_literal = function (param) { + var value = param[1]; + return node("TemplateLiteral", param[0], [ [ - "namespace", - jsx_identifier(namespaced_name.namespace) + "quasis", + array_of_list(template_element, value.quasis) ], [ - "name", - jsx_identifier(namespaced_name.name) + "expressions", + array_of_list(expression, value.expressions) ] ]); }; - var jsx_attribute_value = function (param) { - if (param.TAG === "Literal") { - return literal([ - param._0, - param._1 - ]); - } else { - return jsx_expression_container([ - param._0, - param._1 - ]); - } - }; var type_param = function (param) { var tp = param[1]; var variance = function (param) { - if (param === "Plus") { - return string("plus"); - } else { + if (param) { return string("minus"); + } else { + return string("plus"); } }; return node("TypeParameter", param[0], [ @@ -17252,23 +17365,6 @@ function parse(content, options) { ] ]); }; - var function_type_param = function (param) { - var param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); - }; var class_element = function (m) { if (m.TAG === "Method") { var param = m._0; @@ -17364,270 +17460,150 @@ function parse(content, options) { break; } - return node("ClassProperty", param$1[0], [ + return node("ClassProperty", param$1[0], [ + [ + "key", + match$1[0] + ], + [ + "value", + option(expression, prop.value) + ], + [ + "typeAnnotation", + option(type_annotation, prop.typeAnnotation) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "static", + bool(prop.static) + ] + ]); + } + }; + var comment = function (param) { + var c = param[1]; + var match; + match = c.TAG === "Block" ? [ + "Block", + c._0 + ] : [ + "Line", + c._0 + ]; + return node(match[0], param[0], [[ + "value", + string(match[1]) + ]]); + }; + var function_type_param = function (param) { + var param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ + [ + "name", + identifier(param$1.name) + ], + [ + "typeAnnotation", + _type(param$1.typeAnnotation) + ], + [ + "optional", + bool(param$1.optional) + ] + ]); + }; + var variable_declarator = function (param) { + var declarator = param[1]; + return node("VariableDeclarator", param[0], [ + [ + "id", + pattern(declarator.id) + ], + [ + "init", + option(expression, declarator.init) + ] + ]); + }; + var jsx_attribute_value = function (param) { + if (param.TAG === "Literal") { + return literal([ + param._0, + param._1 + ]); + } else { + return jsx_expression_container([ + param._0, + param._1 + ]); + } + }; + var array_pattern_element = function (p) { + if (p.TAG === "Element") { + return pattern(p._0); + } + var match = p._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) + ]]); + }; + var object_pattern_property = function (param) { + if (param.TAG === "Property") { + var match = param._0; + var prop = match[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG) { + case "Literal" : + match$1 = [ + literal(lit._0), + false + ]; + break; + case "Identifier" : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case "Computed" : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + return node("PropertyPattern", match[0], [ [ "key", match$1[0] ], [ - "value", - option(expression, prop.value) - ], - [ - "typeAnnotation", - option(type_annotation, prop.typeAnnotation) + "pattern", + pattern(prop.pattern) ], [ "computed", bool(match$1[1]) ], [ - "static", - bool(prop.static) - ] - ]); - } - }; - var template_element = function (param) { - var element = param[1]; - var value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ - [ - "value", - value - ], - [ - "tail", - bool(element.tail) - ] - ]); - }; - var jsx_name = function (id) { - switch (id.TAG) { - case "Identifier" : - return jsx_identifier(id._0); - case "NamespacedName" : - return jsx_namespaced_name(id._0); - case "MemberExpression" : - return jsx_member_expression(id._0); - - } - }; - var jsx_opening_attribute = function (attribute) { - if (attribute.TAG === "Attribute") { - var param = attribute._0; - var attribute$1 = param[1]; - var id = attribute$1.name; - var name; - name = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute$1.value) + "shorthand", + bool(prop.shorthand) ] ]); - } else { - var param$1 = attribute._0; - return node("JSXSpreadAttribute", param$1[0], [[ - "argument", - expression(param$1[1].argument) - ]]); - } - }; - var jsx_member_expression = function (param) { - var member_expression = param[1]; - var id = member_expression._object; - var _object; - _object = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ - [ - "object", - _object - ], - [ - "property", - jsx_identifier(member_expression.property) - ] - ]); - }; - var $$case = function (param) { - var c = param[1]; - return node("SwitchCase", param[0], [ - [ - "test", - option(expression, c.test) - ], - [ - "consequent", - array_of_list(statement, c.consequent) - ] - ]); - }; - var $$catch = function (param) { - var c = param[1]; - return node("CatchClause", param[0], [ - [ - "param", - pattern(c.param) - ], - [ - "guard", - option(expression, c.guard) - ], - [ - "body", - block(c.body) - ] - ]); - }; - var export_kind = function (param) { - if (param === "ExportType") { - return "type"; - } else { - return "value"; - } - }; - var declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - var interface_declaration = function (param) { - var i = param[1]; - return node("InterfaceDeclaration", param[0], [ - [ - "id", - identifier(i.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, i.typeParameters) - ], - [ - "body", - object_type(i.body) - ], - [ - "extends", - array_of_list(interface_extends, i.extends) - ] - ]); - }; - var type_alias = function (param) { - var alias = param[1]; - return node("TypeAlias", param[0], [ - [ - "id", - identifier(alias.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) - ], - [ - "right", - _type(alias.right) - ] - ]); - }; - var declare_class = function (param) { - var d = param[1]; - return node("DeclareClass", param[0], [ - [ - "id", - identifier(d.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, d.typeParameters) - ], - [ - "body", - object_type(d.body) - ], - [ - "extends", - array_of_list(interface_extends, d.extends) - ] - ]); - }; - var export_specifiers = function (param) { - if (param !== undefined) { - if (param.TAG === "ExportSpecifiers") { - return array_of_list(export_specifier, param._0); - } else { - return array([node("ExportBatchSpecifier", param._0, [[ - "name", - option(identifier, param._1) - ]])]); - } - } else { - return array([]); - } - }; - var variable_declaration = function (param) { - var $$var = param[1]; - var match = $$var.kind; - var kind; - switch (match) { - case "Var" : - kind = "var"; - break; - case "Let" : - kind = "let"; - break; - case "Const" : - kind = "const"; - break; - } - return node("VariableDeclaration", param[0], [ - [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) - ], - [ - "kind", - string(kind) - ] - ]); - }; - var declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) + var match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ + "argument", + pattern(match$2[1].argument) ]]); }; - var interface_extends = function (param) { - var g = param[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ - [ - "id", - id$1 - ], - [ - "typeParameters", - option(type_parameter_instantiation, g.typeParameters) - ] - ]); - }; var program$2 = function (param) { return node("Program", param[0], [ [ diff --git a/jscomp/test/fun_pattern_match.js b/jscomp/test/fun_pattern_match.js index aa1b6bdae0..c4cf868f52 100644 --- a/jscomp/test/fun_pattern_match.js +++ b/jscomp/test/fun_pattern_match.js @@ -15,10 +15,10 @@ function f3(param) { var lhs = param.rank; return function (param) { var rhs = param.rank; - if (typeof lhs !== "object") { + if (typeof lhs === "string") { lhs === "Uninitialized"; } else { - if (typeof rhs === "object") { + if (typeof rhs !== "string") { return Caml.int_compare(lhs._0, rhs._0); } rhs === "Uninitialized"; @@ -39,10 +39,10 @@ function f4(param) { var lhs = param.rank; return function (param) { var rhs = param.rank; - if (typeof lhs !== "object") { + if (typeof lhs === "string") { lhs === "Uninitialized"; } else { - if (typeof rhs === "object") { + if (typeof rhs !== "string") { return Caml.int_compare(lhs._0, rhs._0); } rhs === "Uninitialized"; diff --git a/jscomp/test/gpr_1658_test.js b/jscomp/test/gpr_1658_test.js index a1d16e8f13..d7ebf14294 100644 --- a/jscomp/test/gpr_1658_test.js +++ b/jscomp/test/gpr_1658_test.js @@ -32,7 +32,7 @@ eq("File \"gpr_1658_test.ml\", line 11, characters 7-14", null, null); var match = Js_types.classify(null); -if (typeof match !== "object" && match === "JSNull") { +if (typeof match === "string" && match === "JSNull") { eq("File \"gpr_1658_test.ml\", line 14, characters 11-18", true, true); } else { eq("File \"gpr_1658_test.ml\", line 16, characters 11-18", true, false); diff --git a/jscomp/test/gpr_3209_test.js b/jscomp/test/gpr_3209_test.js index 1d0f435ec9..e1274256fa 100644 --- a/jscomp/test/gpr_3209_test.js +++ b/jscomp/test/gpr_3209_test.js @@ -2,7 +2,7 @@ function f9(param) { - if (typeof param !== "object") { + if (typeof param === "string") { switch (param) { case "T60" : case "T61" : diff --git a/jscomp/test/gpr_3609_test.js b/jscomp/test/gpr_3609_test.js index eb5ac991ac..a610dcff33 100644 --- a/jscomp/test/gpr_3609_test.js +++ b/jscomp/test/gpr_3609_test.js @@ -2,7 +2,7 @@ function func(state) { - if (typeof state !== "object") { + if (typeof state === "string") { return 0; } else { return 0 + state._0 | 0; diff --git a/jscomp/test/gpr_4519_test.js b/jscomp/test/gpr_4519_test.js index a1cc069080..c635baf30c 100644 --- a/jscomp/test/gpr_4519_test.js +++ b/jscomp/test/gpr_4519_test.js @@ -16,17 +16,17 @@ function eq(loc, x, y) { function nextFor(x) { if (x !== undefined) { - if (x === "Required") { - return "Optional"; - } else { + if (x) { return ; + } else { + return "Optional"; } } else { return "Required"; } } -eq("File \"gpr_4519_test.ml\", line 17, characters 6-13", nextFor("Required"), "Optional"); +eq("File \"gpr_4519_test.ml\", line 17, characters 6-13", "Optional", "Optional"); Mt.from_pair_suites("Gpr_4519_test", suites.contents); diff --git a/jscomp/test/gpr_4900_test.js b/jscomp/test/gpr_4900_test.js index 3c6e35f7bd..02d5735791 100644 --- a/jscomp/test/gpr_4900_test.js +++ b/jscomp/test/gpr_4900_test.js @@ -11,7 +11,7 @@ var test_id = { }; function showToJs(x) { - if (typeof x !== "object" && x === "No") { + if (typeof x === "string" && x === "No") { return false; } else { return true; diff --git a/jscomp/test/gpr_4924_test.js b/jscomp/test/gpr_4924_test.js index 417fa0305f..92bbb605c6 100644 --- a/jscomp/test/gpr_4924_test.js +++ b/jscomp/test/gpr_4924_test.js @@ -11,7 +11,7 @@ var test_id = { }; function u(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return 0; } else { return 1; @@ -19,7 +19,7 @@ function u(b) { } function u1(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return true; } else { return false; @@ -27,7 +27,7 @@ function u1(b) { } function u2(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return false; } else { return true; @@ -41,7 +41,7 @@ Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.ml\", line 26, characters 30 Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.ml\", line 27, characters 30-37", true, true); function u3(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return 3; } else { return 4; @@ -49,7 +49,7 @@ function u3(b) { } function u4(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return 3; } else { return 4; @@ -57,7 +57,7 @@ function u4(b) { } function u5(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return false; } else { return true; @@ -65,7 +65,7 @@ function u5(b) { } function u6(b) { - if (typeof b !== "object" && b === "A") { + if (typeof b === "string" && b === "A") { return true; } else { return false; diff --git a/jscomp/test/gpr_5280_optimize_test.js b/jscomp/test/gpr_5280_optimize_test.js index f986715f6a..7d78503132 100644 --- a/jscomp/test/gpr_5280_optimize_test.js +++ b/jscomp/test/gpr_5280_optimize_test.js @@ -1,14 +1,13 @@ 'use strict'; -var a = { - TAG: "Color", +var a = /* Color */{ _0: "#ffff" }; var c; -c = typeof a !== "object" ? "orange" : "white"; +c = typeof a === "string" ? "orange" : "white"; exports.a = a; exports.c = c; diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index 70085dca5e..35b3ea2754 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -8,7 +8,7 @@ var Caml_option = require("../../lib/js/caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._4; @@ -17,8 +17,7 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -27,8 +26,7 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x, _2: d, @@ -38,11 +36,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -56,7 +54,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -66,8 +64,7 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -75,7 +72,7 @@ function Make(Ord) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -89,7 +86,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -99,16 +96,15 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, param) { - if (typeof param !== "object") { - return { - TAG: "Node", + if (typeof param === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -122,8 +118,7 @@ function Make(Ord) { var l = param._0; var c = Curry._2(Ord.compare, x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, @@ -139,7 +134,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -156,7 +151,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param._1); @@ -170,14 +165,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param._1, param._2 @@ -190,14 +185,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param._1, param._2 @@ -208,7 +203,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -216,14 +211,14 @@ function Make(Ord) { }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._3; } else { return bal(remove_min_binding(l), param._1, param._2, param._3); } }; var remove = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var r = param._3; @@ -232,10 +227,10 @@ function Make(Ord) { var l = param._0; var c = Curry._2(Ord.compare, x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; } - if (typeof r !== "object") { + if (typeof r === "string") { return l; } var match = min_binding(r); @@ -249,7 +244,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param._0); @@ -259,14 +254,13 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: param._1, _2: d$p, @@ -275,15 +269,14 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param._1; var l$p = mapi(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: v, _2: d$p, @@ -295,7 +288,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); @@ -306,7 +299,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -322,7 +315,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -336,25 +329,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, v); } else { return bal(add_min_binding(k, v, param._0), param._1, param._2, param._3); } }; var add_max_binding = function (k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, v); } else { return bal(param._0, param._1, param._2, add_max_binding(k, v, param._3)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l._4; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r._4; @@ -367,10 +360,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -384,7 +377,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -419,8 +412,8 @@ function Make(Ord) { ]; }; var merge = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -432,7 +425,7 @@ function Make(Ord) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -448,7 +441,7 @@ function Make(Ord) { return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); }; var filter = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var d = param._2; @@ -463,7 +456,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -494,11 +487,10 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m._1, _1: m._2, _2: m._3, @@ -514,14 +506,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -543,14 +535,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -565,7 +557,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._3) | 0; @@ -575,7 +567,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param._0; @@ -632,7 +624,7 @@ function Make(Ord) { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._4; @@ -642,8 +634,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -653,8 +644,7 @@ function create(l, x, d, r) { } function singleton(x, d) { - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x, _2: d, @@ -665,11 +655,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -683,7 +673,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -693,8 +683,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -702,7 +691,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -716,7 +705,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -727,7 +716,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -735,9 +724,8 @@ function is_empty(param) { } function add(x, data, param) { - if (typeof param !== "object") { - return { - TAG: "Node", + if (typeof param === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -751,8 +739,7 @@ function add(x, data, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, @@ -769,7 +756,7 @@ function add(x, data, param) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -787,7 +774,7 @@ function find(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.int_compare(x, param._1); @@ -802,14 +789,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param._1, param._2 @@ -823,14 +810,14 @@ function min_binding(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param._1, param._2 @@ -842,7 +829,7 @@ function max_binding(_param) { } function remove_min_binding(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -850,7 +837,7 @@ function remove_min_binding(param) { }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._3; } else { return bal(remove_min_binding(l), param._1, param._2, param._3); @@ -858,7 +845,7 @@ function remove_min_binding(param) { } function remove(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var r = param._3; @@ -867,10 +854,10 @@ function remove(x, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; } - if (typeof r !== "object") { + if (typeof r === "string") { return l; } var match = min_binding(r); @@ -885,7 +872,7 @@ function remove(x, param) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param._0); @@ -896,14 +883,13 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: param._1, _2: d$p, @@ -913,15 +899,14 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param._1; var l$p = mapi(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: v, _2: d$p, @@ -934,7 +919,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); @@ -946,7 +931,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -963,7 +948,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -978,7 +963,7 @@ function exists(p, _param) { } function add_min_binding(k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, v); } else { return bal(add_min_binding(k, v, param._0), param._1, param._2, param._3); @@ -986,7 +971,7 @@ function add_min_binding(k, v, param) { } function add_max_binding(k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, v); } else { return bal(param._0, param._1, param._2, add_max_binding(k, v, param._3)); @@ -994,11 +979,11 @@ function add_max_binding(k, v, param) { } function join(l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l._4; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r._4; @@ -1012,10 +997,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -1031,7 +1016,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -1067,8 +1052,8 @@ function split(x, param) { } function merge(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -1080,7 +1065,7 @@ function merge(f, s1, s2) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1097,7 +1082,7 @@ function merge(f, s1, s2) { } function filter(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var d = param._2; @@ -1113,7 +1098,7 @@ function filter(p, param) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -1145,11 +1130,10 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m._1, _1: m._2, _2: m._3, @@ -1166,14 +1150,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -1196,14 +1180,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (e1._0 !== e2._0) { @@ -1219,7 +1203,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._3) | 0; @@ -1230,7 +1214,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param._0; @@ -1316,7 +1300,7 @@ var m = List.fold_left((function (acc, param) { }); function height$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._4; @@ -1326,8 +1310,7 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -1337,8 +1320,7 @@ function create$1(l, x, d, r) { } function singleton$1(x, d) { - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x, _2: d, @@ -1349,11 +1331,11 @@ function singleton$1(x, d) { function bal$1(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -1367,7 +1349,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); } throw { @@ -1377,8 +1359,7 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -1386,7 +1367,7 @@ function bal$1(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -1400,7 +1381,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); } throw { @@ -1411,7 +1392,7 @@ function bal$1(l, x, d, r) { } function is_empty$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -1419,9 +1400,8 @@ function is_empty$1(param) { } function add$1(x, data, param) { - if (typeof param !== "object") { - return { - TAG: "Node", + if (typeof param === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -1435,8 +1415,7 @@ function add$1(x, data, param) { var l = param._0; var c = Caml.string_compare(x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, @@ -1453,7 +1432,7 @@ function add$1(x, data, param) { function find$1(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1471,7 +1450,7 @@ function find$1(x, _param) { function mem$1(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.string_compare(x, param._1); @@ -1486,14 +1465,14 @@ function mem$1(x, _param) { function min_binding$1(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param._1, param._2 @@ -1507,14 +1486,14 @@ function min_binding$1(_param) { function max_binding$1(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param._1, param._2 @@ -1526,7 +1505,7 @@ function max_binding$1(_param) { } function remove_min_binding$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -1534,7 +1513,7 @@ function remove_min_binding$1(param) { }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._3; } else { return bal$1(remove_min_binding$1(l), param._1, param._2, param._3); @@ -1542,7 +1521,7 @@ function remove_min_binding$1(param) { } function remove$1(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var r = param._3; @@ -1551,10 +1530,10 @@ function remove$1(x, param) { var l = param._0; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; } - if (typeof r !== "object") { + if (typeof r === "string") { return l; } var match = min_binding$1(r); @@ -1569,7 +1548,7 @@ function remove$1(x, param) { function iter$1(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter$1(f, param._0); @@ -1580,14 +1559,13 @@ function iter$1(f, _param) { } function map$1(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map$1(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map$1(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: param._1, _2: d$p, @@ -1597,15 +1575,14 @@ function map$1(f, param) { } function mapi$1(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param._1; var l$p = mapi$1(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi$1(f, param._3); - return { - TAG: "Node", + return /* Node */{ _0: l$p, _1: v, _2: d$p, @@ -1618,7 +1595,7 @@ function fold$1(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m._1, m._2, fold$1(f, m._0, accu)); @@ -1630,7 +1607,7 @@ function fold$1(f, _m, _accu) { function for_all$1(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -1647,7 +1624,7 @@ function for_all$1(p, _param) { function exists$1(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -1662,7 +1639,7 @@ function exists$1(p, _param) { } function add_min_binding$1(k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton$1(k, v); } else { return bal$1(add_min_binding$1(k, v, param._0), param._1, param._2, param._3); @@ -1670,7 +1647,7 @@ function add_min_binding$1(k, v, param) { } function add_max_binding$1(k, v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton$1(k, v); } else { return bal$1(param._0, param._1, param._2, add_max_binding$1(k, v, param._3)); @@ -1678,11 +1655,11 @@ function add_max_binding$1(k, v, param) { } function join$1(l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding$1(v, d, r); } var lh = l._4; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding$1(v, d, l); } var rh = r._4; @@ -1696,10 +1673,10 @@ function join$1(l, v, d, r) { } function concat$1(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding$1(t2); @@ -1715,7 +1692,7 @@ function concat_or_join$1(t1, v, d, t2) { } function split$1(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -1751,8 +1728,8 @@ function split$1(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -1764,7 +1741,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1781,7 +1758,7 @@ function merge$1(f, s1, s2) { } function filter$1(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var d = param._2; @@ -1797,7 +1774,7 @@ function filter$1(p, param) { } function partition$1(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -1829,11 +1806,10 @@ function cons_enum$1(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m._1, _1: m._2, _2: m._3, @@ -1850,14 +1826,14 @@ function compare$1(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -1880,14 +1856,14 @@ function equal$1(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Caml.string_compare(e1._0, e2._0) !== 0) { @@ -1903,7 +1879,7 @@ function equal$1(cmp, m1, m2) { } function cardinal$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal$1(param._0) + 1 | 0) + cardinal$1(param._3) | 0; @@ -1914,7 +1890,7 @@ function bindings_aux$1(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param._0; diff --git a/jscomp/test/inline_map_demo.js b/jscomp/test/inline_map_demo.js index e731598bc5..b7e98c4921 100644 --- a/jscomp/test/inline_map_demo.js +++ b/jscomp/test/inline_map_demo.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return 0; } else { return x._4; @@ -15,8 +15,7 @@ function height(x) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -27,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -49,7 +48,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -63,8 +62,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -72,7 +70,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -90,7 +88,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -105,9 +103,8 @@ function bal(l, x, d, r) { } function add(x, data, tree) { - if (typeof tree !== "object") { - return { - TAG: "Node", + if (typeof tree === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -121,8 +118,7 @@ function add(x, data, tree) { var l = tree._0; var c = Caml.int_compare(x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, @@ -167,7 +163,7 @@ var m = List.fold_left((function (acc, param) { function find(px, _x) { while(true) { var x = _x; - if (typeof x !== "object") { + if (typeof x === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/inline_map_test.js b/jscomp/test/inline_map_test.js index 2393bc1951..e59360bb30 100644 --- a/jscomp/test/inline_map_test.js +++ b/jscomp/test/inline_map_test.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._4; @@ -15,8 +15,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -27,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l._4; + hl = typeof l === "string" ? 0 : l._4; var hr; - hr = typeof r !== "object" ? 0 : r._4; + hr = typeof r === "string" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -45,7 +44,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -55,8 +54,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: d, @@ -64,7 +62,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -78,7 +76,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -89,9 +87,8 @@ function bal(l, x, d, r) { } function add(x, data, param) { - if (typeof param !== "object") { - return { - TAG: "Node", + if (typeof param === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: data, @@ -105,8 +102,7 @@ function add(x, data, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: x, _2: data, @@ -123,7 +119,7 @@ function add(x, data, param) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 2b90b28a8b..15c8bbf6f8 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -17,13 +17,13 @@ function eq(loc, x, y) { } var v = { - TAG: "A0", + TAG: /* A0 */0, lbl: 3, more: /* [] */0 }; var v1 = { - TAG: "A1", + TAG: /* A1 */1, more: { hd: 1, tl: { @@ -88,14 +88,14 @@ function ff(x) { } var v4 = { - TAG: "A0", + TAG: /* A0 */0, x: 0, y: 0, z: 0 }; var v5 = { - TAG: "A1", + TAG: /* A1 */1, z: 0 }; @@ -181,11 +181,10 @@ if (v6.RE_EXN_ID === A4) { eq("File \"inline_record_test.ml\", line 87, characters 6-13", tmp$3, 11); function ff1(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return "A1"; } else { - return { - TAG: "A0", + return /* A0 */{ lbl: x.lbl + 1 | 0, more: x.more }; @@ -194,14 +193,12 @@ function ff1(x) { Mt.from_pair_suites("Inline_record_test", suites.contents); -var v2 = { - TAG: "A0", +var v2 = /* A0 */{ lbl: 3, more: /* [] */0 }; -var vvv = { - TAG: "A0", +var vvv = /* A0 */{ lbl: 3, more: /* [] */0 }; diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index b563f70641..708223fc33 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -15,8 +15,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -26,8 +25,7 @@ function create(l, x, d, r) { } function singleton(x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -38,11 +36,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -56,7 +54,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -66,8 +64,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -75,7 +72,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -89,7 +86,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -100,7 +97,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -108,9 +105,8 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -127,8 +123,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -156,7 +151,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -174,7 +169,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -189,7 +184,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -214,7 +209,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -226,7 +221,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -251,7 +246,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -266,7 +261,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -291,7 +286,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -303,7 +298,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -328,7 +323,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Caml.int_compare(x, param.v); @@ -343,7 +338,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.int_compare(x, param.v); @@ -358,14 +353,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -379,11 +374,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -397,14 +392,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -418,11 +413,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -434,7 +429,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -442,7 +437,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -450,10 +445,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -461,7 +456,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -489,11 +484,10 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -518,8 +512,7 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -547,7 +540,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -558,14 +551,13 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -575,15 +567,14 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -596,7 +587,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -608,7 +599,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -625,7 +616,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -640,7 +631,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -648,7 +639,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -656,11 +647,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -674,10 +665,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -693,7 +684,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -729,8 +720,8 @@ function split(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -742,7 +733,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -759,12 +750,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -792,7 +783,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -814,7 +805,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -846,11 +837,10 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -867,14 +857,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -897,14 +887,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (e1._0 !== e2._0) { @@ -920,7 +910,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -931,7 +921,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index 65db2c777f..733dee33ec 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -61,7 +61,7 @@ var v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param) { var ty = Js_json.classify(v); - if (typeof ty !== "object") { + if (typeof ty === "string") { return { TAG: "Ok", _0: false @@ -81,7 +81,7 @@ add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param }; } var ty2 = Js_json.classify(Caml_option.valFromOption(v$1)); - if (typeof ty2 !== "object") { + if (typeof ty2 === "string") { return { TAG: "Ok", _0: false @@ -95,7 +95,7 @@ add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param } ty2._0.forEach(function (x) { var ty3 = Js_json.classify(x); - if (typeof ty3 !== "object") { + if (typeof ty3 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -131,7 +131,7 @@ var json = JSON.parse(JSON.stringify(null)); var ty = Js_json.classify(json); -if (typeof ty !== "object") { +if (typeof ty === "string") { if (ty === "JSONNull") { add_test("File \"js_json_test.ml\", line 55, characters 24-31", (function (param) { return { @@ -162,7 +162,7 @@ var json$1 = JSON.parse(JSON.stringify("test string")); var ty$1 = Js_json.classify(json$1); -if (typeof ty$1 !== "object") { +if (typeof ty$1 === "string") { add_test("File \"js_json_test.ml\", line 66, characters 16-23", (function (param) { return { TAG: "Ok", @@ -186,7 +186,7 @@ var ty$2 = Js_json.classify(json$2); var exit = 0; -if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { +if (typeof ty$2 === "string" || ty$2.TAG !== "JSONNumber") { exit = 1; } else { eq("File \"js_json_test.ml\", line 75, characters 25-32", ty$2._0, 1.23456789); @@ -207,7 +207,7 @@ var ty$3 = Js_json.classify(json$3); var exit$1 = 0; -if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { +if (typeof ty$3 === "string" || ty$3.TAG !== "JSONNumber") { exit$1 = 1; } else { eq("File \"js_json_test.ml\", line 85, characters 25-32", ty$3._0 | 0, -1347440721); @@ -225,7 +225,7 @@ if (exit$1 === 1) { function test(v) { var json = JSON.parse(JSON.stringify(v)); var ty = Js_json.classify(json); - if (typeof ty === "object") { + if (typeof ty !== "string") { return add_test("File \"js_json_test.ml\", line 97, characters 18-25", (function (param) { return { TAG: "Ok", @@ -277,7 +277,7 @@ var json$4 = JSON.parse(JSON.stringify(dict)); var ty$4 = Js_json.classify(json$4); -if (typeof ty$4 !== "object") { +if (typeof ty$4 === "string") { add_test("File \"js_json_test.ml\", line 135, characters 16-23", (function (param) { return { TAG: "Ok", @@ -287,7 +287,7 @@ if (typeof ty$4 !== "object") { } else if (ty$4.TAG === "JSONObject") { var x = ty$4._0; var ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); - if (typeof ta !== "object") { + if (typeof ta === "string") { add_test("File \"js_json_test.ml\", line 133, characters 18-25", (function (param) { return { TAG: "Ok", @@ -304,7 +304,7 @@ if (typeof ty$4 !== "object") { })); } else { var ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); - if (typeof ty$5 !== "object") { + if (typeof ty$5 === "string") { add_test("File \"js_json_test.ml\", line 131, characters 22-29", (function (param) { return { TAG: "Ok", @@ -348,7 +348,7 @@ if (typeof ty$4 !== "object") { function eq_at_i(loc, json, i, kind, expected) { var ty = Js_json.classify(json); - if (typeof ty !== "object") { + if (typeof ty === "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -367,7 +367,7 @@ function eq_at_i(loc, json, i, kind, expected) { var ty$1 = Js_json.classify(Caml_array.get(ty._0, i)); switch (kind) { case "String" : - if (typeof ty$1 !== "object") { + if (typeof ty$1 === "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -385,7 +385,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Number" : - if (typeof ty$1 !== "object") { + if (typeof ty$1 === "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -403,7 +403,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Object" : - if (typeof ty$1 !== "object") { + if (typeof ty$1 === "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -421,7 +421,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Array" : - if (typeof ty$1 !== "object") { + if (typeof ty$1 === "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -439,7 +439,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Boolean" : - if (typeof ty$1 === "object") { + if (typeof ty$1 !== "string") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -461,7 +461,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Null" : - if (typeof ty$1 !== "object") { + if (typeof ty$1 === "string") { if (ty$1 === "JSONNull") { return add_test(loc, (function (param) { return { @@ -575,7 +575,7 @@ var json$10 = JSON.parse(JSON.stringify(a$3)); var ty$6 = Js_json.classify(json$10); -if (typeof ty$6 !== "object") { +if (typeof ty$6 === "string") { add_test("File \"js_json_test.ml\", line 283, characters 16-23", (function (param) { return { TAG: "Ok", @@ -584,7 +584,7 @@ if (typeof ty$6 !== "object") { })); } else if (ty$6.TAG === "JSONArray") { var ty$7 = Js_json.classify(Caml_array.get(ty$6._0, 1)); - if (typeof ty$7 !== "object") { + if (typeof ty$7 === "string") { add_test("File \"js_json_test.ml\", line 281, characters 18-25", (function (param) { return { TAG: "Ok", @@ -593,7 +593,7 @@ if (typeof ty$6 !== "object") { })); } else if (ty$7.TAG === "JSONObject") { var ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); - if (typeof ty$8 !== "object") { + if (typeof ty$8 === "string") { add_test("File \"js_json_test.ml\", line 279, characters 20-27", (function (param) { return { TAG: "Ok", diff --git a/jscomp/test/large_record_duplication_test.js b/jscomp/test/large_record_duplication_test.js index d996bb4520..8433fe2b9d 100644 --- a/jscomp/test/large_record_duplication_test.js +++ b/jscomp/test/large_record_duplication_test.js @@ -56,8 +56,7 @@ eq("File \"large_record_duplication_test.ml\", line 74, characters 6-13", Caml_o y: "" }), false); -var v1 = { - TAG: "A0", +var v1 = /* A0 */{ x0: 9, x1: 9, x2: 9, @@ -84,7 +83,7 @@ var v1 = { }; function get_x0(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return ; } else { return x.x0; @@ -92,7 +91,7 @@ function get_x0(x) { } function f1(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return "A1"; } var newrecord = Caml_obj.obj_dup(x); @@ -103,7 +102,7 @@ function f1(x) { eq("File \"large_record_duplication_test.ml\", line 140, characters 6-13", get_x0(f1(v1)), 1); var v2 = { - TAG: "A0", + TAG: /* A0 */0, x0: 9, x1: 9, x2: 9, diff --git a/jscomp/test/lexer_test.js b/jscomp/test/lexer_test.js new file mode 100644 index 0000000000..8f7f5a6784 --- /dev/null +++ b/jscomp/test/lexer_test.js @@ -0,0 +1,219 @@ +'use strict'; + +var Mt = require("./mt.js"); +var List = require("../../lib/js/list.js"); +var Curry = require("../../lib/js/curry.js"); +var Lexing = require("../../lib/js/lexing.js"); +var Arith_lexer = require("./arith_lexer.js"); +var Arith_parser = require("./arith_parser.js"); +var Arith_syntax = require("./arith_syntax.js"); +var Number_lexer = require("./number_lexer.js"); + +function get_tokens(lex, str) { + var buf = Lexing.from_string(str); + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var v = Curry._1(lex, buf); + if (v === "EOF") { + return List.rev(acc); + } + _acc = { + hd: v, + tl: acc + }; + continue ; + }; +} + +function f(param) { + return get_tokens(Arith_lexer.lexeme, param); +} + +function from_tokens(lst) { + var l = { + contents: lst + }; + return function (param) { + var match = l.contents; + if (match) { + l.contents = match.tl; + return match.hd; + } + throw { + RE_EXN_ID: "End_of_file", + Error: new Error() + }; + }; +} + +var lexer_suites_0 = [ + "arith_token", + (function (param) { + return { + TAG: "Eq", + _0: get_tokens(Arith_lexer.lexeme, "x + 3 + 4 + y"), + _1: { + hd: { + TAG: "IDENT", + _0: "x" + }, + tl: { + hd: "PLUS", + tl: { + hd: { + TAG: "NUMERAL", + _0: 3 + }, + tl: { + hd: "PLUS", + tl: { + hd: { + TAG: "NUMERAL", + _0: 4 + }, + tl: { + hd: "PLUS", + tl: { + hd: { + TAG: "IDENT", + _0: "y" + }, + tl: /* [] */0 + } + } + } + } + } + } + } + }; + }) +]; + +var lexer_suites_1 = { + hd: [ + "simple token", + (function (param) { + return { + TAG: "Eq", + _0: Arith_lexer.lexeme(Lexing.from_string("10")), + _1: { + TAG: "NUMERAL", + _0: 10 + } + }; + }) + ], + tl: { + hd: [ + "number_lexer", + (function (param) { + var v = { + contents: /* [] */0 + }; + var add = function (t) { + v.contents = { + hd: t, + tl: v.contents + }; + }; + Number_lexer.token(add, Lexing.from_string("32 + 32 ( ) * / ")); + return { + TAG: "Eq", + _0: List.rev(v.contents), + _1: { + hd: "number", + tl: { + hd: "32", + tl: { + hd: "new line", + tl: { + hd: "+", + tl: { + hd: "new line", + tl: { + hd: "number", + tl: { + hd: "32", + tl: { + hd: "new line", + tl: { + hd: "(", + tl: { + hd: "new line", + tl: { + hd: ")", + tl: { + hd: "new line", + tl: { + hd: "*", + tl: { + hd: "new line", + tl: { + hd: "/", + tl: { + hd: "new line", + tl: { + hd: "eof", + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }; + }) + ], + tl: { + hd: [ + "simple number", + (function (param) { + return { + TAG: "Eq", + _0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("10"))), + _1: "10." + }; + }) + ], + tl: { + hd: [ + "arith", + (function (param) { + return { + TAG: "Eq", + _0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("x + 3 + 4 + y"))), + _1: "x+3.+4.+y" + }; + }) + ], + tl: /* [] */0 + } + } + } +}; + +var lexer_suites = { + hd: lexer_suites_0, + tl: lexer_suites_1 +}; + +Mt.from_pair_suites("Lexer_test", lexer_suites); + +exports.get_tokens = get_tokens; +exports.f = f; +exports.from_tokens = from_tokens; +exports.lexer_suites = lexer_suites; +/* Not a pure module */ diff --git a/jscomp/test/map_find_test.js b/jscomp/test/map_find_test.js index eb1e1b756b..62780dd08d 100644 --- a/jscomp/test/map_find_test.js +++ b/jscomp/test/map_find_test.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -15,8 +15,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -27,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -45,7 +44,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -55,8 +54,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -64,7 +62,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -78,7 +76,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -89,9 +87,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -108,8 +105,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -137,7 +133,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -181,7 +177,7 @@ var m = List.fold_left((function (acc, param) { }); function height$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -191,8 +187,7 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -203,11 +198,11 @@ function create$1(l, x, d, r) { function bal$1(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -221,7 +216,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } throw { @@ -231,8 +226,7 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -240,7 +234,7 @@ function bal$1(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -254,7 +248,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } throw { @@ -265,9 +259,8 @@ function bal$1(l, x, d, r) { } function add$1(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -284,8 +277,7 @@ function add$1(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -313,7 +305,7 @@ function add$1(x, data, m) { function find$1(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index 7e9fd04fe8..6b6c80111d 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -6,7 +6,7 @@ var List = require("../../lib/js/list.js"); var Curry = require("../../lib/js/curry.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -16,8 +16,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -28,11 +27,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -46,7 +45,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -56,8 +55,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -65,7 +63,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -79,7 +77,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -90,9 +88,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -109,8 +106,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -139,11 +135,10 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -160,14 +155,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -190,14 +185,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (e1._0 !== e2._0) { @@ -213,7 +208,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -221,7 +216,7 @@ function cardinal(param) { } function height$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -231,8 +226,7 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -243,11 +237,11 @@ function create$1(l, x, d, r) { function bal$1(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -261,7 +255,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } throw { @@ -271,8 +265,7 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -280,7 +273,7 @@ function bal$1(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -294,7 +287,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } throw { @@ -305,9 +298,8 @@ function bal$1(l, x, d, r) { } function add$1(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -324,8 +316,7 @@ function add$1(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -353,7 +344,7 @@ function add$1(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 55e0fa3e32..fee4aacba4 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -58,9 +58,9 @@ function make_enemy(param) { 128 ]); case "GKoopa" : - if (dir === "Left") { + if (dir) { return setup_sprite(undefined, [ - 4, + 1, 10 ], [ 11, @@ -69,12 +69,12 @@ function make_enemy(param) { 16, 27 ], [ - 0, + 32, 69 ]); } else { return setup_sprite(undefined, [ - 1, + 4, 10 ], [ 11, @@ -83,14 +83,14 @@ function make_enemy(param) { 16, 27 ], [ - 32, + 0, 69 ]); } case "RKoopa" : - if (dir === "Left") { + if (dir) { return setup_sprite(undefined, [ - 4, + 1, 10 ], [ 11, @@ -99,12 +99,12 @@ function make_enemy(param) { 16, 27 ], [ - 0, + 32, 5 ]); } else { return setup_sprite(undefined, [ - 1, + 4, 10 ], [ 11, @@ -113,7 +113,7 @@ function make_enemy(param) { 16, 27 ], [ - 32, + 0, 5 ]); } @@ -251,65 +251,65 @@ function make_type(typ, dir) { typ._1, dir ]; - if (pt === "BigM") { + if (pt) { var typ$1 = spr_type[0]; - if (spr_type[1] === "Left") { + if (spr_type[1]) { switch (typ$1) { case "Standing" : return setup_sprite(undefined, [ - 2, + 1, 1 ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ + 11, + 15 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 16, - 5 + 0, + 32 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ + 13, + 15 + ], "mario-small.png", 2, 10, [ 16, - 26 + 16 ], [ - 48, - 6 + 16, + 48 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ + 12, + 15 + ], "mario-small.png", 3, 5, [ 16, - 27 + 16 ], [ - 0, - 37 + 16, + 32 ]); case "Crouching" : return setup_sprite(undefined, [ - 2, - 10 + 1, + 5 ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ + 14, + 10 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 32, - 5 + 0, + 64 ]); } @@ -317,122 +317,122 @@ function make_type(typ, dir) { switch (typ$1) { case "Standing" : return setup_sprite(undefined, [ - 1, + 3, 1 ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ + 11, + 15 + ], "mario-small.png", 1, 0, [ 16, - 26 + 16 ], [ - 16, - 69 + 0, + 0 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ + 13, + 15 + ], "mario-small.png", 2, 10, [ 16, - 26 + 16 ], [ - 48, - 70 + 16, + 16 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ + 12, + 15 + ], "mario-small.png", 3, 5, [ 16, - 27 + 16 ], [ - 0, - 101 + 16, + 0 ]); case "Crouching" : return setup_sprite(undefined, [ - 2, - 10 + 1, + 5 ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ + 14, + 10 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 32, - 69 + 0, + 64 ]); } } } else { var typ$2 = spr_type[0]; - if (spr_type[1] === "Left") { + if (spr_type[1]) { switch (typ$2) { case "Standing" : return setup_sprite(undefined, [ - 3, + 1, 1 ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ + 13, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 0, - 0 + 16, + 69 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ + 12, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 16, - 16 + 48, + 70 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ + 13, + 25 + ], "mario-big.png", 4, 10, [ 16, - 16 + 27 ], [ - 16, - 0 + 0, + 101 ]); case "Crouching" : return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, + 2, 10 - ], "mario-small.png", 1, 0, [ + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 64 + 32, + 69 ]); } @@ -440,59 +440,59 @@ function make_type(typ, dir) { switch (typ$2) { case "Standing" : return setup_sprite(undefined, [ - 1, + 2, 1 ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ + 13, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 32 + 16, + 5 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ + 12, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 16, - 48 + 48, + 6 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ + 13, + 25 + ], "mario-big.png", 4, 10, [ 16, - 16 + 27 ], [ - 16, - 32 + 0, + 37 ]); case "Crouching" : return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, + 2, 10 - ], "mario-small.png", 1, 0, [ + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 64 + 32, + 5 ]); } @@ -554,7 +554,7 @@ function make_type(typ, dir) { } case "SBlock" : var x$1 = typ._0; - if (typeof x$1 === "object") { + if (typeof x$1 !== "string") { return setup_sprite(undefined, undefined, undefined, "blocks.png", 4, 15, [ 16, 16 @@ -803,10 +803,10 @@ function setup_obj(has_gravityOpt, speedOpt, param) { function set_vel_to_speed(obj) { var speed = obj.params.speed; var match = obj.dir; - if (match === "Left") { - obj.vel.x = - speed; - } else { + if (match) { obj.vel.x = speed; + } else { + obj.vel.x = - speed; } } @@ -1358,7 +1358,7 @@ function kill(collid, ctx) { case "Block" : var o$2 = collid._2; var tmp = collid._0; - if (typeof tmp === "object") { + if (typeof tmp !== "string") { return /* [] */0; } if (tmp !== "Brick") { @@ -1695,7 +1695,7 @@ function process_collision(dir, c1, c2, state) { var o2$4 = c2._2; var t = c2._0; if (dir === "North") { - if (typeof t !== "object") { + if (typeof t === "string") { switch (t) { case "Brick" : if (c1._0 === "BigM") { @@ -1736,7 +1736,7 @@ function process_collision(dir, c1, c2, state) { } } else { var exit$1 = 0; - if (typeof t !== "object") { + if (typeof t === "string") { if (t === "Panel") { game_win(state.ctx); return [ @@ -1917,7 +1917,7 @@ function process_collision(dir, c1, c2, state) { var typ$2; switch (t1) { case "GKoopaShell" : - if (typeof t2$3 !== "object") { + if (typeof t2$3 === "string") { if (t2$3 === "Brick") { dec_health(o2$6); reverse_left_right(o1$4); @@ -1933,7 +1933,7 @@ function process_collision(dir, c1, c2, state) { } break; case "RKoopaShell" : - if (typeof t2$3 !== "object") { + if (typeof t2$3 === "string") { if (t2$3 === "Brick") { dec_health(o2$6); reverse_left_right(o1$4); @@ -2538,8 +2538,7 @@ function choose_sblock_typ(typ) { case 2 : return "Cloud"; case 3 : - return { - TAG: "QBlock", + return /* QBlock */{ _0: "Mushroom" }; case 4 : diff --git a/jscomp/test/mutual_non_recursive_type.js b/jscomp/test/mutual_non_recursive_type.js index 3c797680c7..f399ffb306 100644 --- a/jscomp/test/mutual_non_recursive_type.js +++ b/jscomp/test/mutual_non_recursive_type.js @@ -9,8 +9,7 @@ var U = { f: f }; -var v = { - TAG: "H", +var v = /* H */{ _0: "OT" }; diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 7ad266501b..80e1c44f9e 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -293,7 +293,7 @@ function compare(param, param$1) { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -303,8 +303,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -315,11 +314,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -333,7 +332,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -343,8 +342,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -352,7 +350,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -366,7 +364,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -377,9 +375,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -396,8 +393,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -489,7 +485,7 @@ function from_char(param) { } function height$1(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -498,11 +494,10 @@ function height$1(param) { function create$1(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -512,11 +507,11 @@ function create$1(l, v, r) { function bal$1(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -529,7 +524,7 @@ function bal$1(l, v, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, create$1(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create$1(create$1(ll, lv, lr.l), lr.v, create$1(lr.r, v, r)); } throw { @@ -539,15 +534,14 @@ function bal$1(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -560,7 +554,7 @@ function bal$1(l, v, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create$1(create$1(l, v, rl.l), rl.v, create$1(rl.r, rv, rr)); } throw { @@ -571,9 +565,8 @@ function bal$1(l, v, r) { } function add$1(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -717,7 +710,7 @@ function seq$1(ids, kind, x, y) { var match = x.def; var match$1 = y.def; var exit = 0; - if (typeof match !== "object") { + if (typeof match === "string") { return y; } if (match.TAG === "Alt") { @@ -729,7 +722,7 @@ function seq$1(ids, kind, x, y) { exit = 2; } if (exit === 2) { - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { if (kind === "First") { return x; } @@ -749,7 +742,7 @@ function seq$1(ids, kind, x, y) { function is_eps(expr) { var match = expr.def; - if (typeof match !== "object") { + if (typeof match === "string") { return true; } else { return false; @@ -775,7 +768,7 @@ function erase(ids, m, m$p) { function rename(ids, x) { var l = x.def; - if (typeof l !== "object") { + if (typeof l === "string") { return mk_expr(ids, x.def); } switch (l.TAG) { @@ -917,7 +910,7 @@ function tseq(kind, x, y, rem) { switch (match.TAG) { case "TExp" : var tmp = match._1.def; - if (typeof tmp !== "object" && !x.tl) { + if (typeof tmp === "string" && !x.tl) { return { hd: { TAG: "TExp", @@ -1112,7 +1105,7 @@ function remove_duplicates(prev, _l, y) { case "TExp" : var x$2 = x._1; var tmp = x$2.def; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { var r = l.tl; if (List.memq(y.id, prev)) { _l = r; @@ -1212,7 +1205,7 @@ function filter_marks(b, e, marks) { function delta_1(marks, c, next_cat, prev_cat, x, rem) { var s = x.def; - if (typeof s !== "object") { + if (typeof s === "string") { return { hd: { TAG: "TMatch", @@ -1439,8 +1432,7 @@ function status(s) { break; case "TMatch" : var m$1 = m._0; - st$1 = { - TAG: "Match", + st$1 = /* Match */{ _0: flatten_match(m$1.marks), _1: m$1.pmarks }; @@ -1507,7 +1499,7 @@ var unknown_state = { function mk_state(ncol, desc) { var match = status(desc); var break_state; - break_state = typeof match !== "object" && match !== "Failed" ? false : true; + break_state = typeof match === "string" && match !== "Failed" ? false : true; return { idx: break_state ? -3 : desc.idx, real_idx: desc.idx, @@ -1732,7 +1724,7 @@ function trans_set(cache, cm, s) { var _param = cache.contents; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1762,7 +1754,7 @@ function trans_set(cache, cm, s) { function is_charset(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } switch (param.TAG) { @@ -1851,7 +1843,7 @@ function colorize(c, regexp) { var colorize$1 = function (_regexp) { while(true) { var regexp = _regexp; - if (typeof regexp !== "object") { + if (typeof regexp === "string") { switch (regexp) { case "Beg_of_line" : case "End_of_line" : @@ -1936,64 +1928,64 @@ function equal$2(_x1, _x2) { while(true) { var x2 = _x2; var x1 = _x1; - if (typeof x1 !== "object") { + if (typeof x1 === "string") { switch (x1) { case "Beg_of_line" : - if (typeof x2 !== "object" && x2 === "Beg_of_line") { + if (typeof x2 === "string" && x2 === "Beg_of_line") { return true; } else { return false; } case "End_of_line" : - if (typeof x2 !== "object" && x2 === "End_of_line") { + if (typeof x2 === "string" && x2 === "End_of_line") { return true; } else { return false; } case "Beg_of_word" : - if (typeof x2 !== "object" && x2 === "Beg_of_word") { + if (typeof x2 === "string" && x2 === "Beg_of_word") { return true; } else { return false; } case "End_of_word" : - if (typeof x2 !== "object" && x2 === "End_of_word") { + if (typeof x2 === "string" && x2 === "End_of_word") { return true; } else { return false; } case "Not_bound" : - if (typeof x2 !== "object" && x2 === "Not_bound") { + if (typeof x2 === "string" && x2 === "Not_bound") { return true; } else { return false; } case "Beg_of_str" : - if (typeof x2 !== "object" && x2 === "Beg_of_str") { + if (typeof x2 === "string" && x2 === "Beg_of_str") { return true; } else { return false; } case "End_of_str" : - if (typeof x2 !== "object" && x2 === "End_of_str") { + if (typeof x2 === "string" && x2 === "End_of_str") { return true; } else { return false; } case "Last_end_of_line" : - if (typeof x2 !== "object" && x2 === "Last_end_of_line") { + if (typeof x2 === "string" && x2 === "Last_end_of_line") { return true; } else { return false; } case "Start" : - if (typeof x2 !== "object" && x2 === "Start") { + if (typeof x2 === "string" && x2 === "Start") { return true; } else { return false; } case "Stop" : - if (typeof x2 !== "object" && x2 === "Stop") { + if (typeof x2 === "string" && x2 === "Stop") { return true; } else { return false; @@ -2003,25 +1995,25 @@ function equal$2(_x1, _x2) { } else { switch (x1.TAG) { case "Set" : - if (typeof x2 !== "object" || x2.TAG !== "Set") { + if (typeof x2 === "string" || x2.TAG !== "Set") { return false; } else { return Caml_obj.equal(x1._0, x2._0); } case "Sequence" : - if (typeof x2 !== "object" || x2.TAG !== "Sequence") { + if (typeof x2 === "string" || x2.TAG !== "Sequence") { return false; } else { return eq_list(x1._0, x2._0); } case "Alternative" : - if (typeof x2 !== "object" || x2.TAG !== "Alternative") { + if (typeof x2 === "string" || x2.TAG !== "Alternative") { return false; } else { return eq_list(x1._0, x2._0); } case "Repeat" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Repeat") { @@ -2037,7 +2029,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Sem" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Sem") { @@ -2050,7 +2042,7 @@ function equal$2(_x1, _x2) { _x1 = x1._1; continue ; case "Sem_greedy" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Sem_greedy") { @@ -2065,7 +2057,7 @@ function equal$2(_x1, _x2) { case "Group" : return false; case "No_group" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "No_group") { @@ -2075,7 +2067,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Nest" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Nest") { @@ -2085,7 +2077,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Case" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Case") { @@ -2095,7 +2087,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "No_case" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "No_case") { @@ -2105,19 +2097,19 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Intersection" : - if (typeof x2 !== "object" || x2.TAG !== "Intersection") { + if (typeof x2 === "string" || x2.TAG !== "Intersection") { return false; } else { return eq_list(x1._0, x2._0); } case "Complement" : - if (typeof x2 !== "object" || x2.TAG !== "Complement") { + if (typeof x2 === "string" || x2.TAG !== "Complement") { return false; } else { return eq_list(x1._0, x2._0); } case "Difference" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Difference") { @@ -2130,7 +2122,7 @@ function equal$2(_x1, _x2) { _x1 = x1._1; continue ; case "Pmark" : - if (typeof x2 !== "object") { + if (typeof x2 === "string") { return false; } if (x2.TAG !== "Pmark") { @@ -2189,7 +2181,7 @@ function merge_sequences(_param) { return /* [] */0; } var l$p = param.hd; - if (typeof l$p === "object") { + if (typeof l$p !== "string") { switch (l$p.TAG) { case "Sequence" : var match = l$p._0; @@ -2200,7 +2192,7 @@ function merge_sequences(_param) { var exit = 0; if (r$p) { var match$1 = r$p.hd; - if (typeof match$1 !== "object" || match$1.TAG !== "Sequence") { + if (typeof match$1 === "string" || match$1.TAG !== "Sequence") { exit = 2; } else { var match$2 = match$1._0; @@ -2279,7 +2271,7 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _s) var s = _s; var greedy = _greedy; var ign_group = _ign_group; - if (typeof s !== "object") { + if (typeof s === "string") { switch (s) { case "Beg_of_line" : var c$1 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.newline); @@ -2564,7 +2556,7 @@ function case_insens(s) { } function as_set(s) { - if (typeof s !== "object") { + if (typeof s === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -2593,7 +2585,7 @@ function handle_case(_ign_case, _s) { while(true) { var s = _s; var ign_case = _ign_case; - if (typeof s !== "object") { + if (typeof s === "string") { return s; } switch (s.TAG) { @@ -2739,7 +2731,7 @@ function handle_case(_ign_case, _s) { function anchored(_l) { while(true) { var l = _l; - if (typeof l !== "object") { + if (typeof l === "string") { switch (l) { case "Beg_of_str" : case "Start" : @@ -3249,15 +3241,14 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { } res = match[1]; } - if (typeof res !== "object") { + if (typeof res === "string") { if (res === "Failed") { return "Failed"; } else { return "Running"; } } else { - return { - TAG: "Match", + return /* Match */{ _0: { s: s, marks: res._0, @@ -3411,21 +3402,39 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - var regexp$p = function (_left) { - while(true) { - var left = _left; - if (!accept(/* '|' */124)) { - return left; + var piece = function (param) { + var r = atom(undefined); + if (accept(/* '*' */42)) { + return greedy_mod(repn(r, 0, undefined)); + } + if (accept(/* '+' */43)) { + return greedy_mod(repn(r, 1, undefined)); + } + if (accept(/* '?' */63)) { + return greedy_mod(repn(r, 0, 1)); + } + if (!accept(/* '{' */123)) { + return r; + } + var i$1 = integer(undefined); + if (i$1 !== undefined) { + var j = accept(/* ',' */44) ? integer(undefined) : i$1; + if (!accept(/* '}' */125)) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } - _left = alt$1({ - hd: left, - tl: { - hd: branch$p(/* [] */0), - tl: /* [] */0 - } - }); - continue ; - }; + if (j !== undefined && j < i$1) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return greedy_mod(repn(r, i$1, j)); + } + i.contents = i.contents - 1 | 0; + return r; }; var branch$p = function (_left) { while(true) { @@ -3440,173 +3449,135 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; - var $$char = function (param) { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - var c = get(undefined); - if (c === /* '[' */91) { - if (accept(/* '=' */61)) { - throw { - RE_EXN_ID: Not_supported, - Error: new Error() - }; + var atom = function (param) { + if (accept(/* '.' */46)) { + if (dotall) { + return any; + } else { + return notnl; } - if (accept(/* ':' */58)) { - var compl$1 = accept(/* '^' */94); - var cls; - try { - cls = List.find(accept_s, { - hd: "alnum", - tl: { - hd: "ascii", - tl: { - hd: "blank", - tl: { - hd: "cntrl", - tl: { - hd: "digit", - tl: { - hd: "lower", - tl: { - hd: "print", - tl: { - hd: "space", - tl: { - hd: "upper", - tl: { - hd: "word", - tl: { - hd: "punct", - tl: { - hd: "graph", - tl: { - hd: "xdigit", - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - }); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { + } + if (accept(/* '(' */40)) { + if (accept(/* '?' */63)) { + if (accept(/* ':' */58)) { + var r = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - throw exn; + return r; } - if (!accept_s(":]")) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; + if (accept(/* '#' */35)) { + var _param; + while(true) { + if (accept(/* ')' */41)) { + return epsilon; + } + i.contents = i.contents + 1 | 0; + _param = undefined; + continue ; + }; } - var posix_class = posix_class_of_string(cls); - var re = compl$1 ? compl({ - hd: posix_class, - tl: /* [] */0 - }) : posix_class; - return { - NAME: "Set", - VAL: re - }; - } - if (!accept(/* '.' */46)) { - return { - NAME: "Char", - VAL: c - }; - } - if (i.contents === l) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - var c$1 = get(undefined); - if (!accept(/* '.' */46)) { - throw { - RE_EXN_ID: Not_supported, - Error: new Error() - }; - } - if (!accept(/* ']' */93)) { + var r$1 = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } return { - NAME: "Char", - VAL: c$1 + TAG: "Group", + _0: r$1 }; } - if (c !== /* '\\' */92) { - return { - NAME: "Char", - VAL: c - }; + if (accept(/* '^' */94)) { + if (multiline) { + return "Beg_of_line"; + } else { + return "Beg_of_str"; + } } - var c$2 = get(undefined); - if (c$2 >= 58) { - if (c$2 >= 123) { - return { - NAME: "Char", - VAL: c$2 - }; + if (accept(/* '$' */36)) { + if (multiline) { + return "End_of_line"; + } else if (dollar_endonly) { + return "Last_end_of_line"; + } else { + return "End_of_str"; } - switch (c$2) { + } + if (accept(/* '[' */91)) { + if (accept(/* '^' */94)) { + return compl(bracket(/* [] */0)); + } else { + return alt$1(bracket(/* [] */0)); + } + } + if (accept(/* '\\' */92)) { + if (i.contents === l) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + var c = get(undefined); + switch (c) { + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + throw { + RE_EXN_ID: Not_supported, + Error: new Error() + }; + case 65 : + return "Beg_of_str"; + case 66 : + return "Not_bound"; case 68 : - return { - NAME: "Set", - VAL: compl({ - hd: digit, - tl: /* [] */0 - }) - }; + return compl({ + hd: digit, + tl: /* [] */0 + }); + case 71 : + return "Start"; case 83 : - return { - NAME: "Set", - VAL: compl({ - hd: space, - tl: /* [] */0 - }) - }; + return compl({ + hd: space, + tl: /* [] */0 + }); case 87 : - return { - NAME: "Set", - VAL: compl({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; + return compl({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); + case 90 : + return "Last_end_of_line"; case 58 : case 59 : case 60 : @@ -3621,65 +3592,41 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - NAME: "Char", - VAL: c$2 + TAG: "Set", + _0: single(c) }; case 98 : - return { - NAME: "Char", - VAL: /* '\b' */8 - }; + return alt$1({ + hd: "Beg_of_word", + tl: { + hd: "End_of_word", + tl: /* [] */0 + } + }); case 100 : - return { - NAME: "Set", - VAL: digit - }; - case 110 : - return { - NAME: "Char", - VAL: /* '\n' */10 - }; - case 114 : - return { - NAME: "Char", - VAL: /* '\r' */13 - }; + return digit; case 115 : - return { - NAME: "Set", - VAL: space - }; - case 116 : - return { - NAME: "Char", - VAL: /* '\t' */9 - }; + return space; case 119 : - return { - NAME: "Set", - VAL: alt$1({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; - case 65 : - case 66 : + return alt$1({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); case 67 : case 69 : case 70 : - case 71 : case 72 : case 73 : case 74 : @@ -3696,7 +3643,6 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : - case 90 : case 97 : case 99 : case 101 : @@ -3708,33 +3654,126 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : + case 110 : case 111 : case 112 : case 113 : + case 114 : + case 116 : case 117 : case 118 : case 120 : case 121 : - case 122 : throw { RE_EXN_ID: Parse_error, Error: new Error() }; - + case 122 : + return "End_of_str"; + default: + return { + TAG: "Set", + _0: single(c) + }; } } else { - if (c$2 >= 48) { + if (i.contents === l) { throw { - RE_EXN_ID: Not_supported, + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + var c$1 = get(undefined); + if (c$1 >= 64) { + if (c$1 !== 92) { + if (c$1 !== 123) { + return { + TAG: "Set", + _0: single(c$1) + }; + } + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + if (c$1 >= 44) { + if (c$1 >= 63) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return { + TAG: "Set", + _0: single(c$1) + }; + } + if (c$1 >= 42) { + throw { + RE_EXN_ID: Parse_error, Error: new Error() }; } return { - NAME: "Char", - VAL: c$2 + TAG: "Set", + _0: single(c$1) }; } }; + var integer = function (param) { + if (i.contents === l) { + return ; + } + var d = get(undefined); + if (d > 57 || d < 48) { + i.contents = i.contents - 1 | 0; + return ; + } else { + var _i = d - /* '0' */48 | 0; + while(true) { + var i$1 = _i; + if (i.contents === l) { + return i$1; + } + var d$1 = get(undefined); + if (d$1 > 57 || d$1 < 48) { + i.contents = i.contents - 1 | 0; + return i$1; + } + var i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; + if (i$p < i$1) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + _i = i$p; + continue ; + }; + } + }; + var regexp$p = function (_left) { + while(true) { + var left = _left; + if (!accept(/* '|' */124)) { + return left; + } + _left = alt$1({ + hd: left, + tl: { + hd: branch$p(/* [] */0), + tl: /* [] */0 + } + }); + continue ; + }; + }; var bracket = function (_s) { while(true) { var s = _s; @@ -3816,201 +3855,173 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; - var piece = function (param) { - var r = atom(undefined); - if (accept(/* '*' */42)) { - return greedy_mod(repn(r, 0, undefined)); - } - if (accept(/* '+' */43)) { - return greedy_mod(repn(r, 1, undefined)); - } - if (accept(/* '?' */63)) { - return greedy_mod(repn(r, 0, 1)); - } - if (!accept(/* '{' */123)) { - return r; + var $$char = function (param) { + if (i.contents === l) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } - var i$1 = integer(undefined); - if (i$1 !== undefined) { - var j = accept(/* ',' */44) ? integer(undefined) : i$1; - if (!accept(/* '}' */125)) { + var c = get(undefined); + if (c === /* '[' */91) { + if (accept(/* '=' */61)) { throw { - RE_EXN_ID: Parse_error, + RE_EXN_ID: Not_supported, Error: new Error() }; } - if (j !== undefined && j < i$1) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - return greedy_mod(repn(r, i$1, j)); - } - i.contents = i.contents - 1 | 0; - return r; - }; - var integer = function (param) { - if (i.contents === l) { - return ; - } - var d = get(undefined); - if (d > 57 || d < 48) { - i.contents = i.contents - 1 | 0; - return ; - } else { - var _i = d - /* '0' */48 | 0; - while(true) { - var i$1 = _i; - if (i.contents === l) { - return i$1; - } - var d$1 = get(undefined); - if (d$1 > 57 || d$1 < 48) { - i.contents = i.contents - 1 | 0; - return i$1; - } - var i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; - if (i$p < i$1) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; + if (accept(/* ':' */58)) { + var compl$1 = accept(/* '^' */94); + var cls; + try { + cls = List.find(accept_s, { + hd: "alnum", + tl: { + hd: "ascii", + tl: { + hd: "blank", + tl: { + hd: "cntrl", + tl: { + hd: "digit", + tl: { + hd: "lower", + tl: { + hd: "print", + tl: { + hd: "space", + tl: { + hd: "upper", + tl: { + hd: "word", + tl: { + hd: "punct", + tl: { + hd: "graph", + tl: { + hd: "xdigit", + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + }); } - _i = i$p; - continue ; - }; - } - }; - var atom = function (param) { - if (accept(/* '.' */46)) { - if (dotall) { - return any; - } else { - return notnl; - } - } - if (accept(/* '(' */40)) { - if (accept(/* '?' */63)) { - if (accept(/* ':' */58)) { - var r = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - return r; + throw exn; } - if (accept(/* '#' */35)) { - var _param; - while(true) { - if (accept(/* ')' */41)) { - return epsilon; - } - i.contents = i.contents + 1 | 0; - _param = undefined; - continue ; - }; + if (!accept_s(":]")) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } + var posix_class = posix_class_of_string(cls); + var re = compl$1 ? compl({ + hd: posix_class, + tl: /* [] */0 + }) : posix_class; + return { + NAME: "Set", + VAL: re + }; + } + if (!accept(/* '.' */46)) { + return { + NAME: "Char", + VAL: c + }; + } + if (i.contents === l) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - var r$1 = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { + var c$1 = get(undefined); + if (!accept(/* '.' */46)) { + throw { + RE_EXN_ID: Not_supported, + Error: new Error() + }; + } + if (!accept(/* ']' */93)) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } return { - TAG: "Group", - _0: r$1 + NAME: "Char", + VAL: c$1 }; } - if (accept(/* '^' */94)) { - if (multiline) { - return "Beg_of_line"; - } else { - return "Beg_of_str"; - } - } - if (accept(/* '$' */36)) { - if (multiline) { - return "End_of_line"; - } else if (dollar_endonly) { - return "Last_end_of_line"; - } else { - return "End_of_str"; - } - } - if (accept(/* '[' */91)) { - if (accept(/* '^' */94)) { - return compl(bracket(/* [] */0)); - } else { - return alt$1(bracket(/* [] */0)); - } - } - if (accept(/* '\\' */92)) { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() + if (c !== /* '\\' */92) { + return { + NAME: "Char", + VAL: c }; + } + var c$2 = get(undefined); + if (c$2 >= 58) { + if (c$2 >= 123) { + return { + NAME: "Char", + VAL: c$2 + }; } - var c = get(undefined); - switch (c) { - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - throw { - RE_EXN_ID: Not_supported, - Error: new Error() - }; - case 65 : - return "Beg_of_str"; - case 66 : - return "Not_bound"; + switch (c$2) { case 68 : - return compl({ - hd: digit, - tl: /* [] */0 - }); - case 71 : - return "Start"; + return { + NAME: "Set", + VAL: compl({ + hd: digit, + tl: /* [] */0 + }) + }; case 83 : - return compl({ - hd: space, - tl: /* [] */0 - }); - case 87 : - return compl({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, + return { + NAME: "Set", + VAL: compl({ + hd: space, tl: /* [] */0 - } - }); - case 90 : - return "Last_end_of_line"; + }) + }; + case 87 : + return { + NAME: "Set", + VAL: compl({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; case 58 : case 59 : case 60 : @@ -4025,41 +4036,65 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - TAG: "Set", - _0: single(c) + NAME: "Char", + VAL: c$2 }; case 98 : - return alt$1({ - hd: "Beg_of_word", - tl: { - hd: "End_of_word", - tl: /* [] */0 - } - }); + return { + NAME: "Char", + VAL: /* '\b' */8 + }; case 100 : - return digit; + return { + NAME: "Set", + VAL: digit + }; + case 110 : + return { + NAME: "Char", + VAL: /* '\n' */10 + }; + case 114 : + return { + NAME: "Char", + VAL: /* '\r' */13 + }; case 115 : - return space; + return { + NAME: "Set", + VAL: space + }; + case 116 : + return { + NAME: "Char", + VAL: /* '\t' */9 + }; case 119 : - return alt$1({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }); + return { + NAME: "Set", + VAL: alt$1({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; + case 65 : + case 66 : case 67 : case 69 : case 70 : + case 71 : case 72 : case 73 : case 74 : @@ -4076,6 +4111,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : + case 90 : case 97 : case 99 : case 101 : @@ -4087,75 +4123,30 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : - case 110 : case 111 : case 112 : case 113 : - case 114 : - case 116 : case 117 : case 118 : case 120 : case 121 : + case 122 : throw { RE_EXN_ID: Parse_error, Error: new Error() }; - case 122 : - return "End_of_str"; - default: - return { - TAG: "Set", - _0: single(c) - }; + } } else { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - var c$1 = get(undefined); - if (c$1 >= 64) { - if (c$1 !== 92) { - if (c$1 !== 123) { - return { - TAG: "Set", - _0: single(c$1) - }; - } - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - if (c$1 >= 44) { - if (c$1 >= 63) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - return { - TAG: "Set", - _0: single(c$1) - }; - } - if (c$1 >= 42) { + if (c$2 >= 48) { throw { - RE_EXN_ID: Parse_error, + RE_EXN_ID: Not_supported, Error: new Error() }; } return { - TAG: "Set", - _0: single(c$1) + NAME: "Char", + VAL: c$2 }; } }; @@ -4203,7 +4194,7 @@ function re(flagsOpt, pat) { function exec(rex, pos, s) { var len; var substr = exec_internal("Re.exec", pos, len, true, rex, s); - if (typeof substr === "object") { + if (typeof substr !== "string") { return substr._0; } if (substr === "Failed") { diff --git a/jscomp/test/offset.js b/jscomp/test/offset.js index b3a7884756..0b26ec4875 100644 --- a/jscomp/test/offset.js +++ b/jscomp/test/offset.js @@ -7,7 +7,7 @@ var $$String = require("../../lib/js/string.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -16,11 +16,10 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -30,11 +29,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -47,7 +46,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -57,15 +56,14 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -78,7 +76,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -89,9 +87,8 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -122,8 +119,7 @@ function add(x, t) { } function singleton(x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -132,7 +128,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -140,7 +136,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -148,11 +144,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -168,14 +164,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -186,11 +182,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -201,14 +197,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -219,11 +215,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -232,7 +228,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -240,7 +236,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -248,9 +244,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -258,7 +254,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -293,7 +289,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -303,7 +299,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.string_compare(x, param.v); @@ -316,7 +312,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -324,9 +320,9 @@ function remove(x, t) { var l = t.l; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -349,12 +345,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -374,10 +370,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -393,10 +389,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -415,11 +411,10 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -435,14 +430,14 @@ function compare(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -463,13 +458,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -484,8 +479,7 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -496,8 +490,7 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -513,7 +506,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -527,7 +520,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -539,7 +532,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -556,7 +549,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -571,7 +564,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -592,7 +585,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -620,7 +613,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -631,7 +624,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -650,7 +643,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -669,7 +662,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -682,7 +675,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -703,7 +696,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -713,7 +706,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -734,7 +727,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -747,7 +740,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -768,7 +761,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -778,7 +771,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -799,7 +792,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -813,7 +806,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -865,8 +858,7 @@ function of_list(l) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -881,10 +873,8 @@ function of_list(l) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -907,18 +897,15 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/jscomp/test/option_repr_test.js b/jscomp/test/option_repr_test.js index 26ad266f17..860861ffb1 100644 --- a/jscomp/test/option_repr_test.js +++ b/jscomp/test/option_repr_test.js @@ -31,7 +31,7 @@ function f0(x) { } function f1(u) { - if (typeof u !== "object") { + if (typeof u === "string") { return 1; } else { return 0; diff --git a/jscomp/test/pq_test.js b/jscomp/test/pq_test.js index 06c96ac06a..cdca5868fe 100644 --- a/jscomp/test/pq_test.js +++ b/jscomp/test/pq_test.js @@ -3,9 +3,8 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); function insert(queue, prio, elt) { - if (typeof queue !== "object") { - return { - TAG: "Node", + if (typeof queue === "string") { + return /* Node */{ _0: prio, _1: elt, _2: "Empty", @@ -17,16 +16,14 @@ function insert(queue, prio, elt) { var e = queue._1; var p = queue._0; if (prio <= p) { - return { - TAG: "Node", + return /* Node */{ _0: prio, _1: elt, _2: insert(right, p, e), _3: left }; } else { - return { - TAG: "Node", + return /* Node */{ _0: p, _1: e, _2: insert(right, prio, elt), @@ -38,7 +35,7 @@ function insert(queue, prio, elt) { var Queue_is_empty = /* @__PURE__ */Caml_exceptions.create("Pq_test.PrioQueue.Queue_is_empty"); function remove_top(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: Queue_is_empty, Error: new Error() @@ -46,26 +43,24 @@ function remove_top(param) { } var left = param._2; var tmp = param._3; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return left; } - if (typeof left !== "object") { + if (typeof left === "string") { return param._3; } var right = param._3; var rprio = right._0; var lprio = left._0; if (lprio <= rprio) { - return { - TAG: "Node", + return /* Node */{ _0: lprio, _1: left._1, _2: remove_top(left), _3: right }; } else { - return { - TAG: "Node", + return /* Node */{ _0: rprio, _1: right._1, _2: left, @@ -75,7 +70,7 @@ function remove_top(param) { } function extract(queue) { - if (typeof queue === "object") { + if (typeof queue !== "string") { return [ queue._0, queue._1, diff --git a/jscomp/test/rbset.js b/jscomp/test/rbset.js index f389ffab09..40601bcfa7 100644 --- a/jscomp/test/rbset.js +++ b/jscomp/test/rbset.js @@ -2,15 +2,14 @@ function blackify(s) { - if (typeof s !== "object" || s._0 === "Black") { + if (typeof s === "string" || !s._0) { return [ s, true ]; } else { return [ - { - TAG: "Node", + /* Node */{ _0: "Black", _1: s._1, _2: s._2, @@ -22,7 +21,7 @@ function blackify(s) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -32,7 +31,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var y = param._2; @@ -57,12 +56,12 @@ function balance_left(l, x, r) { var c; var z; var d; - if (typeof l !== "object" || l._0 === "Black") { + if (typeof l === "string" || !l._0) { exit = 1; } else { var a$1 = l._1; var exit$1 = 0; - if (typeof a$1 !== "object" || a$1._0 === "Black") { + if (typeof a$1 === "string" || !a$1._0) { exit$1 = 3; } else { a = a$1._1; @@ -76,7 +75,7 @@ function balance_left(l, x, r) { } if (exit$1 === 3) { var match = l._3; - if (typeof match !== "object" || match._0 === "Black") { + if (typeof match === "string" || !match._0) { exit = 1; } else { a = a$1; @@ -93,27 +92,23 @@ function balance_left(l, x, r) { } switch (exit) { case 1 : - return { - TAG: "Node", + return /* Node */{ _0: "Black", _1: l, _2: x, _3: r }; case 2 : - return { - TAG: "Node", + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: a, _2: x$1, _3: b }, _2: y, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: c, _2: z, @@ -133,12 +128,12 @@ function balance_right(l, x, r) { var c; var z; var d; - if (typeof r !== "object" || r._0 === "Black") { + if (typeof r === "string" || !r._0) { exit = 1; } else { var b$1 = r._1; var exit$1 = 0; - if (typeof b$1 !== "object" || b$1._0 === "Black") { + if (typeof b$1 === "string" || !b$1._0) { exit$1 = 3; } else { a = l; @@ -152,7 +147,7 @@ function balance_right(l, x, r) { } if (exit$1 === 3) { var match = r._3; - if (typeof match !== "object" || match._0 === "Black") { + if (typeof match === "string" || !match._0) { exit = 1; } else { a = l; @@ -169,27 +164,23 @@ function balance_right(l, x, r) { } switch (exit) { case 1 : - return { - TAG: "Node", + return /* Node */{ _0: "Black", _1: l, _2: x, _3: r }; case 2 : - return { - TAG: "Node", + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: a, _2: x$1, _3: b }, _2: y, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: c, _2: z, @@ -201,8 +192,7 @@ function balance_right(l, x, r) { } function singleton(x) { - return { - TAG: "Node", + return /* Node */{ _0: "Black", _1: "Empty", _2: x, @@ -211,36 +201,47 @@ function singleton(x) { } function unbalanced_left(param) { - if (typeof param === "object") { - if (param._0 === "Black") { + if (typeof param !== "string") { + if (param._0) { var match = param._1; - if (typeof match === "object") { - if (match._0 === "Black") { + if (typeof match !== "string" && !match._0) { + return [ + balance_left(/* Node */{ + _0: "Red", + _1: match._1, + _2: match._2, + _3: match._3 + }, param._2, param._3), + false + ]; + } + + } else { + var match$1 = param._1; + if (typeof match$1 !== "string") { + if (!match$1._0) { return [ - balance_left({ - TAG: "Node", + balance_left(/* Node */{ _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 }, param._2, param._3), true ]; } - var match$1 = match._3; - if (typeof match$1 === "object" && match$1._0 === "Black") { + var match$2 = match$1._3; + if (typeof match$2 !== "string" && !match$2._0) { return [ - { - TAG: "Node", + /* Node */{ _0: "Black", - _1: match._1, - _2: match._2, - _3: balance_left({ - TAG: "Node", + _1: match$1._1, + _2: match$1._2, + _3: balance_left(/* Node */{ _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 }, param._2, param._3) }, false @@ -249,21 +250,6 @@ function unbalanced_left(param) { } - } else { - var match$2 = param._1; - if (typeof match$2 === "object" && match$2._0 === "Black") { - return [ - balance_left({ - TAG: "Node", - _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 - }, param._2, param._3), - false - ]; - } - } } throw { @@ -278,39 +264,50 @@ function unbalanced_left(param) { } function unbalanced_right(param) { - if (typeof param === "object") { - if (param._0 === "Black") { + if (typeof param !== "string") { + if (param._0) { var match = param._3; + if (typeof match !== "string" && !match._0) { + return [ + balance_right(param._1, param._2, /* Node */{ + _0: "Red", + _1: match._1, + _2: match._2, + _3: match._3 + }), + false + ]; + } + + } else { + var match$1 = param._3; var x = param._2; var a = param._1; - if (typeof match === "object") { - if (match._0 === "Black") { + if (typeof match$1 !== "string") { + if (!match$1._0) { return [ - balance_right(a, x, { - TAG: "Node", + balance_right(a, x, /* Node */{ _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 }), true ]; } - var match$1 = match._1; - if (typeof match$1 === "object" && match$1._0 === "Black") { + var match$2 = match$1._1; + if (typeof match$2 !== "string" && !match$2._0) { return [ - { - TAG: "Node", + /* Node */{ _0: "Black", - _1: balance_right(a, x, { - TAG: "Node", + _1: balance_right(a, x, /* Node */{ _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 }), - _2: match._2, - _3: match._3 + _2: match$1._2, + _3: match$1._3 }, false ]; @@ -318,21 +315,6 @@ function unbalanced_right(param) { } - } else { - var match$2 = param._3; - if (typeof match$2 === "object" && match$2._0 === "Black") { - return [ - balance_right(param._1, param._2, { - TAG: "Node", - _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 - }), - false - ]; - } - } } throw { @@ -347,18 +329,16 @@ function unbalanced_right(param) { } function lbalance(x1, x2, x3) { - if (typeof x1 !== "object") { - return { - TAG: "Node", + if (typeof x1 === "string") { + return /* Node */{ _0: "Black", _1: x1, _2: x2, _3: x3 }; } - if (x1._0 === "Black") { - return { - TAG: "Node", + if (!x1._0) { + return /* Node */{ _0: "Black", _1: x1, _2: x2, @@ -367,20 +347,17 @@ function lbalance(x1, x2, x3) { } var r = x1._3; var l = x1._1; - if (typeof l === "object" && l._0 !== "Black") { - return { - TAG: "Node", + if (typeof l !== "string" && l._0) { + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: l._1, _2: l._2, _3: l._3 }, _2: x1._2, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: r, _2: x2, @@ -388,18 +365,16 @@ function lbalance(x1, x2, x3) { } }; } - if (typeof r !== "object") { - return { - TAG: "Node", + if (typeof r === "string") { + return /* Node */{ _0: "Black", _1: x1, _2: x2, _3: x3 }; } - if (r._0 === "Black") { - return { - TAG: "Node", + if (!r._0) { + return /* Node */{ _0: "Black", _1: x1, _2: x2, @@ -407,19 +382,16 @@ function lbalance(x1, x2, x3) { }; } var y = r._2; - return { - TAG: "Node", + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: l, _2: y, _3: r._1 }, _2: y, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: r._3, _2: x2, @@ -429,26 +401,23 @@ function lbalance(x1, x2, x3) { } function rbalance(x1, x2, x3) { - if (typeof x3 === "object" && x3._0 !== "Black") { + if (typeof x3 !== "string" && x3._0) { var b = x3._1; var exit = 0; - if (typeof b !== "object") { + if (typeof b === "string") { exit = 2; } else { - if (b._0 !== "Black") { - return { - TAG: "Node", + if (b._0) { + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: x1, _2: x2, _3: b._1 }, _2: b._2, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: b._3, _2: x3._2, @@ -460,20 +429,17 @@ function rbalance(x1, x2, x3) { } if (exit === 2) { var match = x3._3; - if (typeof match === "object" && match._0 !== "Black") { - return { - TAG: "Node", + if (typeof match !== "string" && match._0) { + return /* Node */{ _0: "Red", - _1: { - TAG: "Node", + _1: /* Node */{ _0: "Black", _1: x1, _2: x2, _3: b }, _2: x3._2, - _3: { - TAG: "Node", + _3: /* Node */{ _0: "Black", _1: match._1, _2: match._2, @@ -485,8 +451,7 @@ function rbalance(x1, x2, x3) { } } - return { - TAG: "Node", + return /* Node */{ _0: "Black", _1: x1, _2: x2, @@ -495,16 +460,15 @@ function rbalance(x1, x2, x3) { } function ins(x, s) { - if (typeof s !== "object") { - return { - TAG: "Node", + if (typeof s === "string") { + return /* Node */{ _0: "Red", _1: "Empty", _2: x, _3: "Empty" }; } - if (s._0 === "Black") { + if (s._0) { var y = s._2; if (x === y) { return s; @@ -512,9 +476,19 @@ function ins(x, s) { var b = s._3; var a = s._1; if (x < y) { - return lbalance(ins(x, a), y, b); + return /* Node */{ + _0: "Red", + _1: ins(x, a), + _2: y, + _3: b + }; } else { - return rbalance(a, y, ins(x, b)); + return /* Node */{ + _0: "Red", + _1: a, + _2: y, + _3: ins(x, b) + }; } } var y$1 = s._2; @@ -524,31 +498,18 @@ function ins(x, s) { var b$1 = s._3; var a$1 = s._1; if (x < y$1) { - return { - TAG: "Node", - _0: "Red", - _1: ins(x, a$1), - _2: y$1, - _3: b$1 - }; + return lbalance(ins(x, a$1), y$1, b$1); } else { - return { - TAG: "Node", - _0: "Red", - _1: a$1, - _2: y$1, - _3: ins(x, b$1) - }; + return rbalance(a$1, y$1, ins(x, b$1)); } } function add(x, s) { var s$1 = ins(x, s); - if (typeof s$1 !== "object" || s$1._0 === "Black") { + if (typeof s$1 === "string" || !s$1._0) { return s$1; } else { - return { - TAG: "Node", + return /* Node */{ _0: "Black", _1: s$1._1, _2: s$1._2, @@ -558,7 +519,7 @@ function add(x, s) { } function remove_min(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -570,22 +531,31 @@ function remove_min(param) { }; } var c = param._0; - if (c === "Black") { + if (c) { var tmp = param._1; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { + return [ + param._3, + param._2, + false + ]; + } + + } else { + var tmp$1 = param._1; + if (typeof tmp$1 === "string") { var match = param._3; var x = param._2; - if (typeof match !== "object") { + if (typeof match === "string") { return [ "Empty", x, true ]; } - if (match._0 !== "Black") { + if (match._0) { return [ - { - TAG: "Node", + /* Node */{ _0: "Black", _1: match._1, _2: match._2, @@ -606,24 +576,13 @@ function remove_min(param) { }; } - } else { - var tmp$1 = param._1; - if (typeof tmp$1 !== "object") { - return [ - param._3, - param._2, - false - ]; - } - } var match$1 = remove_min(param._1); var y = match$1[1]; var s_1 = match$1[0]; var s_2 = param._2; var s_3 = param._3; - var s = { - TAG: "Node", + var s = /* Node */{ _0: c, _1: s_1, _2: s_2, @@ -645,7 +604,7 @@ function remove_min(param) { } function remove_aux(x, n) { - if (typeof n !== "object") { + if (typeof n === "string") { return [ "Empty", false @@ -656,7 +615,7 @@ function remove_aux(x, n) { var l = n._1; var c = n._0; if (x === y) { - if (typeof r !== "object") { + if (typeof r === "string") { if (c === "Red") { return [ l, @@ -669,8 +628,7 @@ function remove_aux(x, n) { var match = remove_min(r); var n_2 = match[1]; var n_3 = match[0]; - var n$1 = { - TAG: "Node", + var n$1 = /* Node */{ _0: c, _1: l, _2: n_2, @@ -688,8 +646,7 @@ function remove_aux(x, n) { if (x < y) { var match$1 = remove_aux(x, l); var n_1 = match$1[0]; - var n$2 = { - TAG: "Node", + var n$2 = /* Node */{ _0: c, _1: n_1, _2: y, @@ -706,8 +663,7 @@ function remove_aux(x, n) { } var match$2 = remove_aux(x, r); var n_3$1 = match$2[0]; - var n$3 = { - TAG: "Node", + var n$3 = /* Node */{ _0: c, _1: l, _2: y, @@ -728,7 +684,7 @@ function remove(x, s) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (1 + cardinal(param._1) | 0) + cardinal(param._3) | 0; diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js index 8ed6c0b347..1dafbab9ab 100644 --- a/jscomp/test/rec_module_test.js +++ b/jscomp/test/rec_module_test.js @@ -95,7 +95,7 @@ var AAA = { }; function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -104,11 +104,10 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -118,11 +117,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -135,7 +134,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -145,15 +144,14 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -166,7 +164,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -177,9 +175,8 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -210,8 +207,7 @@ function add(x, t) { } function singleton(x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -220,7 +216,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -228,7 +224,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -236,11 +232,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -256,14 +252,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -274,11 +270,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -289,14 +285,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -307,11 +303,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -320,7 +316,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -328,7 +324,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -336,9 +332,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -346,7 +342,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -381,7 +377,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -391,7 +387,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(AAA.compare, x, param.v); @@ -404,7 +400,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -412,9 +408,9 @@ function remove(x, t) { var l = t.l; var c = Curry._2(AAA.compare, x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -437,12 +433,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -462,10 +458,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -481,10 +477,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -503,11 +499,10 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -523,14 +518,14 @@ function compare$1(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(AAA.compare, e1._0, e2._0); @@ -551,13 +546,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -572,8 +567,7 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -584,8 +578,7 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -601,7 +594,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -615,7 +608,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -627,7 +620,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -644,7 +637,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -659,7 +652,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -680,7 +673,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -708,7 +701,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -719,7 +712,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -738,7 +731,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -757,7 +750,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -770,7 +763,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -791,7 +784,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -801,7 +794,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -822,7 +815,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -835,7 +828,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -856,7 +849,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -866,7 +859,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -887,7 +880,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -901,7 +894,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -953,8 +946,7 @@ function of_list(l) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -969,10 +961,8 @@ function of_list(l) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -995,18 +985,15 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/jscomp/test/record_extension_test.js b/jscomp/test/record_extension_test.js index d38f8acf70..bcf91beadc 100644 --- a/jscomp/test/record_extension_test.js +++ b/jscomp/test/record_extension_test.js @@ -36,7 +36,7 @@ var v0 = { eq("File \"record_extension_test.ml\", line 19, characters 6-13", f(v0), 7); function f2(x) { - if (typeof x !== "object" || x.TAG !== "C") { + if (typeof x === "string" || x.TAG !== "C") { return 0; } else { return x.x; @@ -44,11 +44,11 @@ function f2(x) { } function f2_with(x) { - if (typeof x !== "object" || x.TAG !== "C") { + if (typeof x === "string" || x.TAG !== "C") { return x; } else { return { - TAG: "C", + TAG: /* C */0, x: 0, y: x.y }; diff --git a/jscomp/test/recursive_records_test.js b/jscomp/test/recursive_records_test.js index cf39ab22c1..7c2d08cc55 100644 --- a/jscomp/test/recursive_records_test.js +++ b/jscomp/test/recursive_records_test.js @@ -47,8 +47,7 @@ rec_cell2.next = rec_cell2; function f2(x) { var rec_cell2 = {}; - Caml_obj.update_dummy(rec_cell2, { - TAG: "Cons", + Caml_obj.update_dummy(rec_cell2, /* Cons */{ content: Math.imul(x, x) - 6 | 0, next: rec_cell2 }); @@ -56,7 +55,7 @@ function f2(x) { } function hd(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return 0; } else { return x.content; @@ -64,7 +63,7 @@ function hd(x) { } function tl_exn(x) { - if (typeof x === "object") { + if (typeof x !== "string") { return x.next; } throw { diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index 5be4594226..2e9a6fe7b5 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -9,11 +9,10 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s._1, _1: s._2, _2: e @@ -24,7 +23,7 @@ function cons_enum(_s, _e) { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._3; @@ -34,14 +33,14 @@ function height(param) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._1; } _param = l; @@ -52,14 +51,14 @@ function min_elt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._2; - if (typeof r !== "object") { + if (typeof r === "string") { return param._1; } _param = r; @@ -68,7 +67,7 @@ function max_elt(_param) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -79,7 +78,7 @@ function cardinal_aux(_acc, _param) { while(true) { var param = _param; var acc = _acc; - if (typeof param !== "object") { + if (typeof param === "string") { return acc; } _param = param._0; @@ -96,7 +95,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param._0; @@ -115,7 +114,7 @@ function elements(s) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param._0); @@ -129,7 +128,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s._1, fold(f, s._0, accu)); @@ -141,7 +140,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param._1)) { @@ -158,7 +157,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param._1)) { @@ -199,7 +198,7 @@ var Height_invariant_broken = /* @__PURE__ */Caml_exceptions.create("Set_gen.Hei var Height_diff_borken = /* @__PURE__ */Caml_exceptions.create("Set_gen.Height_diff_borken"); function check_height_and_diff(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } var h = param._3; @@ -227,11 +226,10 @@ function check(tree) { function create(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l._3; + hl = typeof l === "string" ? 0 : l._3; var hr; - hr = typeof r !== "object" ? 0 : r._3; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r._3; + return /* Node */{ _0: l, _1: v, _2: r, @@ -241,11 +239,11 @@ function create(l, v, r) { function internal_bal(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l._3; + hl = typeof l === "string" ? 0 : l._3; var hr; - hr = typeof r !== "object" ? 0 : r._3; + hr = typeof r === "string" ? 0 : r._3; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -262,7 +260,7 @@ function internal_bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } throw { @@ -276,15 +274,14 @@ function internal_bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: v, _2: r, _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -301,7 +298,7 @@ function internal_bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } throw { @@ -316,7 +313,7 @@ function internal_bal(l, v, r) { } function remove_min_elt(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -324,7 +321,7 @@ function remove_min_elt(param) { }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._2; } else { return internal_bal(remove_min_elt(l), param._1, param._2); @@ -332,8 +329,7 @@ function remove_min_elt(param) { } function singleton(x) { - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x, _2: "Empty", @@ -342,9 +338,9 @@ function singleton(x) { } function internal_merge(l, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return internal_bal(l, min_elt(r), remove_min_elt(r)); @@ -352,7 +348,7 @@ function internal_merge(l, r) { } function add_min_element(v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(v); } else { return internal_bal(add_min_element(v, param._0), param._1, param._2); @@ -360,7 +356,7 @@ function add_min_element(v, param) { } function add_max_element(v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(v); } else { return internal_bal(param._0, param._1, add_max_element(v, param._2)); @@ -368,11 +364,11 @@ function add_max_element(v, param) { } function internal_join(l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l._3; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r._3; @@ -386,9 +382,9 @@ function internal_join(l, v, r) { } function internal_concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return internal_join(t1, min_elt(t2), remove_min_elt(t2)); @@ -396,7 +392,7 @@ function internal_concat(t1, t2) { } function filter(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param._1; @@ -411,7 +407,7 @@ function filter(p, param) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -449,8 +445,7 @@ function of_sorted_list(l) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", @@ -465,10 +460,8 @@ function of_sorted_list(l) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - _0: { - TAG: "Node", + /* Node */{ + _0: /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", @@ -491,18 +484,15 @@ function of_sorted_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - _0: { - TAG: "Node", + /* Node */{ + _0: /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", _3: 1 }, _1: match$1.hd, - _2: { - TAG: "Node", + _2: /* Node */{ _0: "Empty", _1: match$2.hd, _2: "Empty", @@ -551,8 +541,7 @@ function of_sorted_array(l) { } if (n === 1) { var x0 = l[start]; - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x0, _2: "Empty", @@ -562,10 +551,8 @@ function of_sorted_array(l) { if (n === 2) { var x0$1 = l[start]; var x1 = l[start + 1 | 0]; - return { - TAG: "Node", - _0: { - TAG: "Node", + return /* Node */{ + _0: /* Node */{ _0: "Empty", _1: x0$1, _2: "Empty", @@ -580,18 +567,15 @@ function of_sorted_array(l) { var x0$2 = l[start]; var x1$1 = l[start + 1 | 0]; var x2 = l[start + 2 | 0]; - return { - TAG: "Node", - _0: { - TAG: "Node", + return /* Node */{ + _0: /* Node */{ _0: "Empty", _1: x0$2, _2: "Empty", _3: 1 }, _1: x1$1, - _2: { - TAG: "Node", + _2: /* Node */{ _0: "Empty", _1: x2, _2: "Empty", @@ -612,7 +596,7 @@ function of_sorted_array(l) { function is_ordered(cmp, tree) { var is_ordered_min_max = function (tree) { - if (typeof tree !== "object") { + if (typeof tree === "string") { return "Empty"; } var r = tree._2; @@ -691,14 +675,14 @@ function compare_aux(cmp, _e1, _e2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(cmp, e1._0, e2._0); diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index 9fb703e624..f375fe33a2 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -7,7 +7,7 @@ var $$String = require("../../lib/js/string.js"); var Set_gen = require("./set_gen.js"); function split(x, tree) { - if (typeof tree !== "object") { + if (typeof tree === "string") { return [ "Empty", false, @@ -42,9 +42,8 @@ function split(x, tree) { } function add(x, tree) { - if (typeof tree !== "object") { - return { - TAG: "Node", + if (typeof tree === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: "Empty", @@ -65,12 +64,12 @@ function add(x, tree) { } function union(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1._3; var v1 = s1._1; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2._3; @@ -90,10 +89,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1._2; @@ -109,10 +108,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1._2; @@ -130,7 +129,7 @@ function diff(s1, s2) { function mem(x, _tree) { while(true) { var tree = _tree; - if (typeof tree !== "object") { + if (typeof tree === "string") { return false; } var c = Caml.string_compare(x, tree._1); @@ -143,7 +142,7 @@ function mem(x, _tree) { } function remove(x, tree) { - if (typeof tree !== "object") { + if (typeof tree === "string") { return "Empty"; } var r = tree._2; @@ -171,13 +170,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1._2; var v1 = s1._1; var l1 = s1._0; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2._2; @@ -192,8 +191,7 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ _0: l1, _1: v1, _2: "Empty", @@ -204,8 +202,7 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ _0: "Empty", _1: v1, _2: r1, @@ -221,7 +218,7 @@ function subset(_s1, _s2) { function find(x, _tree) { while(true) { var tree = _tree; - if (typeof tree !== "object") { + if (typeof tree === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index e13603dda4..4ab731c177 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -12,19 +12,17 @@ function fib(n) { } function cons(x, y) { - return { - TAG: "Cons", + return /* Cons */{ _0: x, _1: y }; } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Nil"; } else { - return { - TAG: "Cons", + return /* Cons */{ _0: Curry._1(f, param._0), _1: map(f, param._1) }; diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index 6d0f322d05..a3fb89b395 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -35,15 +35,14 @@ for(var i$1 = 10; i$1 >= 0; --i$1){ var sumdown = v$1; function cons(x, y) { - return { - TAG: "Cons", + return /* Cons */{ _0: x, _1: y }; } function length(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return 0; } else { return 1 + length(x._1) | 0; @@ -51,11 +50,10 @@ function length(x) { } function map(f, x) { - if (typeof x !== "object") { + if (typeof x === "string") { return "Nil"; } else { - return { - TAG: "Cons", + return /* Cons */{ _0: Curry._1(f, x._0), _1: map(f, x._1) }; diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 094f35ed0f..30936c384a 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -15,8 +15,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -26,8 +25,7 @@ function create(l, x, d, r) { } function singleton(x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -38,11 +36,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -56,7 +54,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -66,8 +64,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -75,7 +72,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -89,7 +86,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -100,7 +97,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -108,9 +105,8 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -127,8 +123,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -156,7 +151,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -174,7 +169,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -189,7 +184,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -214,7 +209,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -226,7 +221,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -251,7 +246,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -266,7 +261,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -291,7 +286,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -303,7 +298,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -328,7 +323,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Caml.int_compare(x, param.v); @@ -343,7 +338,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.int_compare(x, param.v); @@ -358,14 +353,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -379,11 +374,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -397,14 +392,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -418,11 +413,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -434,7 +429,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -442,7 +437,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -450,10 +445,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -461,7 +456,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -489,11 +484,10 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -518,8 +512,7 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -547,7 +540,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -558,14 +551,13 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -575,15 +567,14 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -596,7 +587,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -608,7 +599,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -625,7 +616,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -640,7 +631,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -648,7 +639,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -656,11 +647,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -674,10 +665,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -693,7 +684,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -729,8 +720,8 @@ function split(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -742,7 +733,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -759,12 +750,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -792,7 +783,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -814,7 +805,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -846,11 +837,10 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -867,14 +857,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -897,14 +887,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (e1._0 !== e2._0) { @@ -920,7 +910,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -931,7 +921,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/jscomp/test/test_int_map_find.js b/jscomp/test/test_int_map_find.js index 2ff25cea4f..1c819a403c 100644 --- a/jscomp/test/test_int_map_find.js +++ b/jscomp/test/test_int_map_find.js @@ -4,7 +4,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -26,11 +25,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -44,7 +43,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -54,8 +53,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -63,7 +61,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -77,7 +75,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -88,9 +86,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -107,8 +104,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index d861c7b7db..f95985cf9c 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param._3; @@ -13,11 +13,10 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l._3; + hl = typeof l === "string" ? 0 : l._3; var hr; - hr = typeof r !== "object" ? 0 : r._3; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r._3; + return /* Node */{ _0: l, _1: v, _2: r, @@ -26,11 +25,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l._3; + hl = typeof l === "string" ? 0 : l._3; var hr; - hr = typeof r !== "object" ? 0 : r._3; + hr = typeof r === "string" ? 0 : r._3; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -43,7 +42,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } throw { @@ -53,15 +52,14 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ _0: l, _1: v, _2: r, _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -74,7 +72,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } throw { @@ -84,9 +82,8 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ _0: "Empty", _1: x, _2: "Empty", @@ -106,8 +103,7 @@ function Make(Ord) { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ _0: "Empty", _1: x, _2: "Empty", @@ -115,25 +111,25 @@ function Make(Ord) { }; }; var add_min_element = function (v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(v); } else { return bal(add_min_element(v, param._0), param._1, param._2); } }; var add_max_element = function (v, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(v); } else { return bal(param._0, param._1, add_max_element(v, param._2)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l._3; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r._3; @@ -148,14 +144,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._1; } _param = l; @@ -165,14 +161,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._2; - if (typeof r !== "object") { + if (typeof r === "string") { return param._1; } _param = r; @@ -180,7 +176,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -188,32 +184,32 @@ function Make(Ord) { }; } var l = param._0; - if (typeof l !== "object") { + if (typeof l === "string") { return param._2; } else { return bal(remove_min_elt(l), param._1, param._2); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -247,7 +243,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -256,7 +252,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param._1); @@ -268,7 +264,7 @@ function Make(Ord) { }; }; var remove = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var r = param._2; @@ -284,12 +280,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1._3; var v1 = s1._1; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2._3; @@ -308,10 +304,10 @@ function Make(Ord) { return join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1._2; @@ -326,10 +322,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1._2; @@ -347,11 +343,10 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s._1, _1: s._2, _2: e @@ -364,14 +359,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -393,13 +388,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1._2; var v1 = s1._1; var l1 = s1._0; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2._2; @@ -414,8 +409,7 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ _0: l1, _1: v1, _2: "Empty", @@ -426,8 +420,7 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ _0: "Empty", _1: v1, _2: r1, @@ -442,7 +435,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param._0); @@ -455,7 +448,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s._1, fold(f, s._0, accu)); @@ -466,7 +459,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param._1)) { @@ -482,7 +475,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param._1)) { @@ -496,7 +489,7 @@ function Make(Ord) { }; }; var filter = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param._1; @@ -510,7 +503,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -537,7 +530,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._2) | 0; @@ -547,7 +540,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param._0; @@ -564,7 +557,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -590,8 +583,7 @@ function Make(Ord) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", @@ -606,10 +598,8 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - _0: { - TAG: "Node", + /* Node */{ + _0: /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", @@ -632,18 +622,15 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - _0: { - TAG: "Node", + /* Node */{ + _0: /* Node */{ _0: "Empty", _1: l.hd, _2: "Empty", _3: 1 }, _1: match$1.hd, - _2: { - TAG: "Node", + _2: /* Node */{ _0: "Empty", _1: match$2.hd, _2: "Empty", diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index 91ed2a5069..6b0af6d8aa 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -4,7 +4,7 @@ var Caml = require("../../lib/js/caml.js"); var Curry = require("../../lib/js/curry.js"); function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -26,11 +25,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -44,7 +43,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -54,8 +53,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -63,7 +61,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -77,7 +75,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -88,9 +86,8 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -107,8 +104,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -136,7 +132,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/test_switch.js b/jscomp/test/test_switch.js index 7aa9544cf0..7ac9a0dcb8 100644 --- a/jscomp/test/test_switch.js +++ b/jscomp/test/test_switch.js @@ -3,7 +3,7 @@ var Curry = require("../../lib/js/curry.js"); function f(param) { - if (typeof param !== "object") { + if (typeof param === "string") { if (param === "G") { return 4; } else { diff --git a/jscomp/test/test_trywith.js b/jscomp/test/test_trywith.js index 2965f2da53..6780759f26 100644 --- a/jscomp/test/test_trywith.js +++ b/jscomp/test/test_trywith.js @@ -123,7 +123,7 @@ function u(param) { } function f(x) { - if (typeof x !== "object") { + if (typeof x === "string") { return 2; } if (x.TAG === "D") { diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 0cac60a5f0..ffc33f3b14 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -67,7 +67,7 @@ var Util = { }; function string_of_rank(i) { - if (typeof i !== "object") { + if (typeof i === "string") { if (i === "Uninitialized") { return "Uninitialized"; } else { @@ -87,7 +87,7 @@ function find_ticker_by_name(all_tickers, ticker) { function print_all_composite(all_tickers) { List.iter((function (param) { var tmp = param.type_; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return ; } console.log(param.ticker_name); @@ -95,7 +95,7 @@ function print_all_composite(all_tickers) { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -105,8 +105,7 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -116,8 +115,7 @@ function create(l, x, d, r) { } function singleton(x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -128,11 +126,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -146,7 +144,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -156,8 +154,7 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -165,7 +162,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -179,7 +176,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -190,7 +187,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -198,9 +195,8 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -217,8 +213,7 @@ function add(x, data, m) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -246,7 +241,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -264,7 +259,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -279,7 +274,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -304,7 +299,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -316,7 +311,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -341,7 +336,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -356,7 +351,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -381,7 +376,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -393,7 +388,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -418,7 +413,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Caml_obj.compare(x, param.v); @@ -433,7 +428,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml_obj.compare(x, param.v); @@ -448,14 +443,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -469,11 +464,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -487,14 +482,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -508,11 +503,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -524,7 +519,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -532,7 +527,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -540,10 +535,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -551,7 +546,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -579,11 +574,10 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -608,8 +602,7 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -637,7 +630,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -648,14 +641,13 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -665,15 +657,14 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -686,7 +677,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -698,7 +689,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -715,7 +706,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -730,7 +721,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -738,7 +729,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -746,11 +737,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -764,10 +755,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -783,7 +774,7 @@ function concat_or_join(t1, v, d, t2) { } function split$1(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -819,8 +810,8 @@ function split$1(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -832,7 +823,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -849,12 +840,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -882,7 +873,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -904,7 +895,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -936,11 +927,10 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -957,14 +947,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml_obj.compare(e1._0, e2._0); @@ -987,14 +977,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (!Caml_obj.equal(e1._0, e2._0)) { @@ -1010,7 +1000,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1021,7 +1011,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -1081,7 +1071,7 @@ function compute_update_sequences(all_tickers) { List.fold_left((function (counter, ticker) { var loop = function (counter, ticker) { var rank = ticker.rank; - if (typeof rank === "object") { + if (typeof rank !== "string") { return counter; } if (rank !== "Uninitialized") { @@ -1089,10 +1079,9 @@ function compute_update_sequences(all_tickers) { } ticker.rank = "Visited"; var match = ticker.type_; - if (typeof match !== "object") { + if (typeof match === "string") { var counter$1 = counter + 1 | 0; - ticker.rank = { - TAG: "Ranked", + ticker.rank = /* Ranked */{ _0: counter$1 }; return counter$1; @@ -1101,8 +1090,7 @@ function compute_update_sequences(all_tickers) { var counter$2 = loop(counter, match$1.lhs); var counter$3 = loop(counter$2, match$1.rhs); var counter$4 = counter$3 + 1 | 0; - ticker.rank = { - TAG: "Ranked", + ticker.rank = /* Ranked */{ _0: counter$4 }; return counter$4; @@ -1111,7 +1099,7 @@ function compute_update_sequences(all_tickers) { }), 0, all_tickers); var map = List.fold_left((function (map, ticker) { var tmp = ticker.type_; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return add(ticker.ticker_name, { hd: ticker, tl: /* [] */0 @@ -1124,7 +1112,7 @@ function compute_update_sequences(all_tickers) { var up = _up; var type_ = ticker.type_; var ticker_name = ticker.ticker_name; - if (typeof type_ !== "object") { + if (typeof type_ === "string") { var l = find(ticker_name, map); return add(ticker_name, Pervasives.$at(up, l), map); } @@ -1147,7 +1135,7 @@ function compute_update_sequences(all_tickers) { return fold((function (k, l, map) { var l$1 = List.sort_uniq((function (lhs, rhs) { var x = lhs.rank; - if (typeof x !== "object") { + if (typeof x === "string") { if (x === "Uninitialized") { throw { RE_EXN_ID: "Failure", @@ -1162,7 +1150,7 @@ function compute_update_sequences(all_tickers) { }; } else { var y = rhs.rank; - if (typeof y === "object") { + if (typeof y !== "string") { return Caml.int_compare(x._0, y._0); } if (y === "Uninitialized") { @@ -1187,7 +1175,7 @@ function process_quote(ticker_map, new_ticker, new_value) { var update_sequence = find(new_ticker, ticker_map); List.iter((function (ticker) { var match = ticker.type_; - if (typeof match !== "object") { + if (typeof match === "string") { if (ticker.ticker_name === new_ticker) { ticker.value = new_value; return ; @@ -1202,7 +1190,7 @@ function process_quote(ticker_map, new_ticker, new_value) { var match$2 = match$1.lhs.value; var match$3 = match$1.rhs.value; var value = match$2 !== undefined && match$3 !== undefined ? ( - match$1.op === "PLUS" ? match$2 + match$3 : match$2 - match$3 + match$1.op ? match$2 - match$3 : match$2 + match$3 ) : undefined; ticker.value = value; }), update_sequence); @@ -1216,8 +1204,7 @@ function process_input_line(ticker_map, all_tickers, line) { value: undefined, rank: "Uninitialized", ticker_name: ticker_name, - type_: { - TAG: "Binary_op", + type_: /* Binary_op */{ _0: { op: op, rhs: rhs$1, diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index f67b7745f0..d47fcc995b 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -451,7 +451,7 @@ if (!Caml_obj.equal(unsafe_topsort(grwork), { } function height(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -460,11 +460,10 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -474,11 +473,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -491,7 +490,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -501,15 +500,14 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -522,7 +520,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -533,9 +531,8 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -566,8 +563,7 @@ function add(x, t) { } function singleton(x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -576,7 +572,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -584,7 +580,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -592,11 +588,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -612,14 +608,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -630,11 +626,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -645,14 +641,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -663,11 +659,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -676,7 +672,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -684,7 +680,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -692,9 +688,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -702,7 +698,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -737,7 +733,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -747,7 +743,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Caml.string_compare(x, param.v); @@ -760,7 +756,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -768,9 +764,9 @@ function remove(x, t) { var l = t.l; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -793,12 +789,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -818,10 +814,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -837,10 +833,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -859,11 +855,10 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -879,14 +874,14 @@ function compare(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -907,13 +902,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -928,8 +923,7 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -940,8 +934,7 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -957,7 +950,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -971,7 +964,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -983,7 +976,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -1000,7 +993,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -1015,7 +1008,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1036,7 +1029,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -1064,7 +1057,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1075,7 +1068,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -1094,7 +1087,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1113,7 +1106,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1126,7 +1119,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -1147,7 +1140,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1157,7 +1150,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -1178,7 +1171,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1191,7 +1184,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -1212,7 +1205,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1222,7 +1215,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -1243,7 +1236,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1257,7 +1250,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1309,8 +1302,7 @@ function of_list(l) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1325,10 +1317,8 @@ function of_list(l) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1351,18 +1341,15 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/jscomp/test/typeof_test.js b/jscomp/test/typeof_test.js index 2a9808d982..2853962abc 100644 --- a/jscomp/test/typeof_test.js +++ b/jscomp/test/typeof_test.js @@ -5,7 +5,7 @@ var Js_types = require("../../lib/js/js_types.js"); function string_or_number(x) { var ty = Js_types.classify(x); - if (typeof ty !== "object") { + if (typeof ty === "string") { switch (ty) { case "JSFalse" : case "JSTrue" : diff --git a/jscomp/test/utf8_decode_test.js b/jscomp/test/utf8_decode_test.js index 554061f0f1..dcf4c2635c 100644 --- a/jscomp/test/utf8_decode_test.js +++ b/jscomp/test/utf8_decode_test.js @@ -60,7 +60,7 @@ function utf8_decode(strm) { } Stream.junk(strm); var c = classify(chr); - if (typeof c !== "object") { + if (typeof c === "string") { throw { RE_EXN_ID: Stream.$$Error, _1: "Invalid byte", @@ -85,7 +85,7 @@ function utf8_decode(strm) { return c; } var cc = classify(Stream.next(strm)); - if (typeof cc !== "object") { + if (typeof cc === "string") { throw { RE_EXN_ID: Stream.$$Error, _1: "Continuation byte expected", @@ -129,7 +129,7 @@ function utf8_list(s) { function decode(bytes, offset) { var c = classify(Caml_bytes.get(bytes, offset)); - if (typeof c !== "object") { + if (typeof c === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "decode", @@ -163,7 +163,7 @@ function decode(bytes, offset) { ]; } var cc = classify(Caml_bytes.get(bytes, offset$1)); - if (typeof cc !== "object") { + if (typeof cc === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "decode", diff --git a/jscomp/test/variant.js b/jscomp/test/variant.js index afc72b427a..af4318e849 100644 --- a/jscomp/test/variant.js +++ b/jscomp/test/variant.js @@ -6,7 +6,7 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); var Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function foo(n) { - if (typeof n !== "object") { + if (typeof n === "string") { if (n === "A1") { return 1; } else { @@ -26,7 +26,7 @@ function foo(n) { } function fooA1(param) { - if (typeof param !== "object" && param === "A1") { + if (typeof param === "string" && param === "A1") { return 1; } else { return 42; @@ -34,7 +34,7 @@ function fooA1(param) { } function fooC(param) { - if (typeof param !== "object" || param.TAG !== "C") { + if (typeof param === "string" || param.TAG !== "C") { return 42; } else { return param._0 + param._1 | 0; diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index 0f01f32e67..e44aa3eca9 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -68,7 +68,7 @@ function not_(x) { } function st(state) { - if (typeof state !== "object") { + if (typeof state === "string") { return 0; } else { return 23; @@ -76,7 +76,7 @@ function st(state) { } function showToJs(x) { - if (typeof x !== "object" && x === "No") { + if (typeof x === "string" && x === "No") { return false; } else { return true; @@ -106,28 +106,28 @@ function third(l) { } function third2(l) { - if (typeof l !== "object") { + if (typeof l === "string") { return false; } if (l._0 !== 1) { return false; } var match = l._1; - if (typeof match !== "object") { + if (typeof match === "string") { return false; } if (match._0 !== 2) { return false; } var match$1 = match._1; - if (typeof match$1 !== "object") { + if (typeof match$1 === "string") { return false; } if (match$1._0 !== 3) { return false; } var tmp = match$1._1; - if (typeof tmp !== "object") { + if (typeof tmp === "string") { return true; } else { return false; diff --git a/lib/es6/caml_module.js b/lib/es6/caml_module.js index d7bbd0121d..359609d41c 100644 --- a/lib/es6/caml_module.js +++ b/lib/es6/caml_module.js @@ -11,7 +11,7 @@ function init_mod(loc, shape) { }; }; var loop = function (shape, struct_, idx) { - if (typeof shape !== "object") { + if (typeof shape === "string") { switch (shape) { case "Function" : struct_[idx] = undef_module; @@ -56,7 +56,7 @@ function init_mod(loc, shape) { function update_mod(shape, o, n) { var aux = function (shape, o, n, parent, i) { - if (typeof shape !== "object") { + if (typeof shape === "string") { switch (shape) { case "Function" : parent[i] = n; @@ -79,7 +79,7 @@ function update_mod(shape, o, n) { return ; } }; - if (typeof shape !== "object") { + if (typeof shape === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index cebb4dea6d..8fdba4a319 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -92,7 +92,7 @@ function reset(h) { } function copy_bucketlist(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var key = param.key; @@ -102,19 +102,18 @@ function copy_bucketlist(param) { while(true) { var param = _param; var prec = _prec; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var key = param.key; var data = param.data; var next = param.next; - var r = { - TAG: "Cons", + var r = /* Cons */{ key: key, data: data, next: next }; - if (typeof prec !== "object") { + if (typeof prec === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -131,8 +130,7 @@ function copy_bucketlist(param) { continue ; }; }; - var r = { - TAG: "Cons", + var r = /* Cons */{ key: key, data: data, next: next @@ -168,21 +166,20 @@ function resize(indexfun, h) { var insert_bucket = function (_cell) { while(true) { var cell = _cell; - if (typeof cell !== "object") { + if (typeof cell === "string") { return ; } var key = cell.key; var data = cell.data; var next = cell.next; - var cell$1 = inplace ? cell : ({ - TAG: "Cons", + var cell$1 = inplace ? cell : /* Cons */({ key: key, data: data, next: "Empty" }); var nidx = Curry._2(indexfun, h, key); var tail = Caml_array.get(ndata_tail, nidx); - if (typeof tail !== "object") { + if (typeof tail === "string") { Caml_array.set(ndata, nidx, cell$1); } else { tail.next = cell$1; @@ -200,7 +197,7 @@ function resize(indexfun, h) { } for(var i$1 = 0; i$1 < nsize; ++i$1){ var tail = Caml_array.get(ndata_tail, i$1); - if (typeof tail === "object") { + if (typeof tail !== "string") { tail.next = "Empty"; } @@ -213,8 +210,7 @@ function key_index(h, key) { function add(h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -234,14 +230,14 @@ function remove(h, key) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Caml_obj.equal(k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -256,7 +252,7 @@ function remove(h, key) { function find(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -268,7 +264,7 @@ function find(h, key) { if (Caml_obj.equal(key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -280,7 +276,7 @@ function find(h, key) { if (Caml_obj.equal(key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -295,7 +291,7 @@ function find(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -315,7 +311,7 @@ function find(h, key) { function find_opt(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -324,7 +320,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -333,7 +329,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -345,7 +341,7 @@ function find_opt(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -364,7 +360,7 @@ function find_all(h, key) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -386,7 +382,7 @@ function find_all(h, key) { function replace_bucket(key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -405,8 +401,7 @@ function replace(h, key, data) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -425,7 +420,7 @@ function mem(h, key) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; @@ -442,7 +437,7 @@ function iter(f, h) { var do_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var key = param.key; @@ -481,8 +476,8 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { while(true) { var slot = _slot; var prec = _prec; - if (typeof slot !== "object") { - if (typeof prec !== "object") { + if (typeof slot === "string") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, "Empty"); } else { prec.next = "Empty"; @@ -494,7 +489,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { var next = slot.next; var data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { - if (typeof prec !== "object") { + if (typeof prec === "string") { Caml_array.set(h.data, i, slot); } else { prec.next = slot; @@ -536,7 +531,7 @@ function fold(f, h, init) { while(true) { var accu = _accu; var b = _b; - if (typeof b !== "object") { + if (typeof b === "string") { return accu; } var key = b.key; @@ -575,7 +570,7 @@ function bucket_length(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } var next = param.next; @@ -608,8 +603,7 @@ function MakeSeeded(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -628,14 +622,14 @@ function MakeSeeded(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -649,7 +643,7 @@ function MakeSeeded(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -661,7 +655,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -673,7 +667,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -688,7 +682,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -707,7 +701,7 @@ function MakeSeeded(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -716,7 +710,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -725,7 +719,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -737,7 +731,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -755,7 +749,7 @@ function MakeSeeded(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -776,7 +770,7 @@ function MakeSeeded(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -794,8 +788,7 @@ function MakeSeeded(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -813,7 +806,7 @@ function MakeSeeded(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; @@ -852,8 +845,7 @@ function Make(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -872,14 +864,14 @@ function Make(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -893,7 +885,7 @@ function Make(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -905,7 +897,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -917,7 +909,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -932,7 +924,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -951,7 +943,7 @@ function Make(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -960,7 +952,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -969,7 +961,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -981,7 +973,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -999,7 +991,7 @@ function Make(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -1020,7 +1012,7 @@ function Make(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -1038,8 +1030,7 @@ function Make(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -1057,7 +1048,7 @@ function Make(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; diff --git a/lib/es6/map.js b/lib/es6/map.js index 91a7429f04..349d22ba66 100644 --- a/lib/es6/map.js +++ b/lib/es6/map.js @@ -5,7 +5,7 @@ import * as Caml_option from "./caml_option.js"; function Make(funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function Make(funarg) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -24,8 +23,7 @@ function Make(funarg) { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -35,11 +33,11 @@ function Make(funarg) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -53,7 +51,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -63,8 +61,7 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -72,7 +69,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +83,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -96,16 +93,15 @@ function Make(funarg) { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -122,8 +118,7 @@ function Make(funarg) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -150,7 +145,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -167,7 +162,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -182,7 +177,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -206,7 +201,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -218,7 +213,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -242,7 +237,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -257,7 +252,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -281,7 +276,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -293,7 +288,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -317,7 +312,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -331,7 +326,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -345,14 +340,14 @@ function Make(funarg) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -365,11 +360,11 @@ function Make(funarg) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -382,14 +377,14 @@ function Make(funarg) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -402,11 +397,11 @@ function Make(funarg) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -417,7 +412,7 @@ function Make(funarg) { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -425,24 +420,24 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -469,11 +464,10 @@ function Make(funarg) { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -498,8 +492,7 @@ function Make(funarg) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -526,7 +519,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -536,14 +529,13 @@ function Make(funarg) { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -552,15 +544,14 @@ function Make(funarg) { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -572,7 +563,7 @@ function Make(funarg) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -583,7 +574,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -599,7 +590,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -613,25 +604,25 @@ function Make(funarg) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -644,10 +635,10 @@ function Make(funarg) { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -661,7 +652,7 @@ function Make(funarg) { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -696,8 +687,8 @@ function Make(funarg) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -709,7 +700,7 @@ function Make(funarg) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -725,12 +716,12 @@ function Make(funarg) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -757,7 +748,7 @@ function Make(funarg) { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -778,7 +769,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -809,11 +800,10 @@ function Make(funarg) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -829,14 +819,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -858,14 +848,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -880,7 +870,7 @@ function Make(funarg) { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -890,7 +880,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/lib/es6/mapLabels.js b/lib/es6/mapLabels.js index f30f682b0e..6b5b442156 100644 --- a/lib/es6/mapLabels.js +++ b/lib/es6/mapLabels.js @@ -5,7 +5,7 @@ import * as Caml_option from "./caml_option.js"; function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -24,8 +23,7 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -35,11 +33,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -53,7 +51,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -63,8 +61,7 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -72,7 +69,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +83,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -96,16 +93,15 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -122,8 +118,7 @@ function Make(Ord) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -150,7 +145,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -169,7 +164,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -189,7 +184,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -208,7 +203,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -228,7 +223,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -244,7 +239,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -264,7 +259,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -283,7 +278,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -303,7 +298,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -317,7 +312,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(Ord.compare, x, param.v); @@ -331,7 +326,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -345,14 +340,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -365,11 +360,11 @@ function Make(Ord) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -382,14 +377,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -402,11 +397,11 @@ function Make(Ord) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -417,7 +412,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -425,24 +420,24 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -469,11 +464,10 @@ function Make(Ord) { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -498,8 +492,7 @@ function Make(Ord) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -526,7 +519,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -536,14 +529,13 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -552,15 +544,14 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -572,7 +563,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -583,7 +574,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -599,7 +590,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -613,25 +604,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -644,10 +635,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -661,7 +652,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -696,8 +687,8 @@ function Make(Ord) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -709,7 +700,7 @@ function Make(Ord) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -725,12 +716,12 @@ function Make(Ord) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -757,7 +748,7 @@ function Make(Ord) { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -778,7 +769,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -809,11 +800,10 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -829,14 +819,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -858,14 +848,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -880,7 +870,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -890,7 +880,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/lib/es6/moreLabels.js b/lib/es6/moreLabels.js index b3dcca38d3..d3f63805c3 100644 --- a/lib/es6/moreLabels.js +++ b/lib/es6/moreLabels.js @@ -35,7 +35,7 @@ var Hashtbl = { var $$Map = { Make: (function (funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -44,8 +44,7 @@ var $$Map = { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -54,8 +53,7 @@ var $$Map = { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -65,11 +63,11 @@ var $$Map = { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +81,7 @@ var $$Map = { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -93,8 +91,7 @@ var $$Map = { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -102,7 +99,7 @@ var $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -116,7 +113,7 @@ var $$Map = { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -126,16 +123,15 @@ var $$Map = { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -152,8 +148,7 @@ var $$Map = { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -180,7 +175,7 @@ var $$Map = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -199,7 +194,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -219,7 +214,7 @@ var $$Map = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -238,7 +233,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -258,7 +253,7 @@ var $$Map = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -274,7 +269,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -294,7 +289,7 @@ var $$Map = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -313,7 +308,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -333,7 +328,7 @@ var $$Map = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -347,7 +342,7 @@ var $$Map = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -361,7 +356,7 @@ var $$Map = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -375,14 +370,14 @@ var $$Map = { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -395,11 +390,11 @@ var $$Map = { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -412,14 +407,14 @@ var $$Map = { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -432,11 +427,11 @@ var $$Map = { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -447,7 +442,7 @@ var $$Map = { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -455,24 +450,24 @@ var $$Map = { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -499,11 +494,10 @@ var $$Map = { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -528,8 +522,7 @@ var $$Map = { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -556,7 +549,7 @@ var $$Map = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -566,14 +559,13 @@ var $$Map = { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -582,15 +574,14 @@ var $$Map = { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -602,7 +593,7 @@ var $$Map = { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -613,7 +604,7 @@ var $$Map = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -629,7 +620,7 @@ var $$Map = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -643,25 +634,25 @@ var $$Map = { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -674,10 +665,10 @@ var $$Map = { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -691,7 +682,7 @@ var $$Map = { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -726,8 +717,8 @@ var $$Map = { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -739,7 +730,7 @@ var $$Map = { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -755,12 +746,12 @@ var $$Map = { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -787,7 +778,7 @@ var $$Map = { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -808,7 +799,7 @@ var $$Map = { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -839,11 +830,10 @@ var $$Map = { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -859,14 +849,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -888,14 +878,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -910,7 +900,7 @@ var $$Map = { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -920,7 +910,7 @@ var $$Map = { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -979,7 +969,7 @@ var $$Map = { var $$Set = { Make: (function (funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -987,11 +977,10 @@ var $$Set = { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -1000,11 +989,11 @@ var $$Set = { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1017,7 +1006,7 @@ var $$Set = { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -1027,15 +1016,14 @@ var $$Set = { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1048,7 +1036,7 @@ var $$Set = { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -1058,9 +1046,8 @@ var $$Set = { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -1090,8 +1077,7 @@ var $$Set = { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -1099,25 +1085,25 @@ var $$Set = { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -1132,14 +1118,14 @@ var $$Set = { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -1149,11 +1135,11 @@ var $$Set = { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -1163,14 +1149,14 @@ var $$Set = { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -1180,11 +1166,11 @@ var $$Set = { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -1192,7 +1178,7 @@ var $$Set = { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -1200,32 +1186,32 @@ var $$Set = { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -1259,7 +1245,7 @@ var $$Set = { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -1268,7 +1254,7 @@ var $$Set = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -1280,7 +1266,7 @@ var $$Set = { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1306,12 +1292,12 @@ var $$Set = { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -1330,10 +1316,10 @@ var $$Set = { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -1348,10 +1334,10 @@ var $$Set = { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -1369,11 +1355,10 @@ var $$Set = { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -1386,14 +1371,14 @@ var $$Set = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -1415,13 +1400,13 @@ var $$Set = { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -1436,8 +1421,7 @@ var $$Set = { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -1448,8 +1432,7 @@ var $$Set = { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -1464,7 +1447,7 @@ var $$Set = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -1477,7 +1460,7 @@ var $$Set = { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -1488,7 +1471,7 @@ var $$Set = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -1504,7 +1487,7 @@ var $$Set = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -1518,7 +1501,7 @@ var $$Set = { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1538,7 +1521,7 @@ var $$Set = { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -1565,7 +1548,7 @@ var $$Set = { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1575,7 +1558,7 @@ var $$Set = { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -1592,7 +1575,7 @@ var $$Set = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1611,7 +1594,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -1627,7 +1610,7 @@ var $$Set = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1645,7 +1628,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -1661,7 +1644,7 @@ var $$Set = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1676,7 +1659,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -1692,7 +1675,7 @@ var $$Set = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1710,7 +1693,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -1726,7 +1709,7 @@ var $$Set = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1740,7 +1723,7 @@ var $$Set = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1760,7 +1743,7 @@ var $$Set = { } }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1786,8 +1769,7 @@ var $$Set = { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1802,10 +1784,8 @@ var $$Set = { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1828,18 +1808,15 @@ var $$Set = { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/queue.js b/lib/es6/queue.js index d9282aa6ff..9f72c2f151 100644 --- a/lib/es6/queue.js +++ b/lib/es6/queue.js @@ -20,13 +20,12 @@ function clear(q) { } function add(x, q) { - var cell = { - TAG: "Cons", + var cell = /* Cons */{ content: x, next: "Nil" }; var last = q.last; - if (typeof last !== "object") { + if (typeof last === "string") { q.length = 1; q.first = cell; q.last = cell; @@ -39,7 +38,7 @@ function add(x, q) { function peek(q) { var match = q.first; - if (typeof match === "object") { + if (typeof match !== "string") { return match.content; } throw { @@ -50,7 +49,7 @@ function peek(q) { function take(q) { var match = q.first; - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: Empty, Error: new Error() @@ -58,7 +57,7 @@ function take(q) { } var content = match.content; var next = match.next; - if (typeof next !== "object") { + if (typeof next === "string") { clear(q); return content; } @@ -78,17 +77,16 @@ function copy(q) { while(true) { var cell = _cell; var prev = _prev; - if (typeof cell !== "object") { + if (typeof cell === "string") { q_res.last = prev; return q_res; } var next = cell.next; - var res = { - TAG: "Cons", + var res = /* Cons */{ content: cell.content, next: "Nil" }; - if (typeof prev !== "object") { + if (typeof prev === "string") { q_res.first = res; } else { prev.next = res; @@ -111,7 +109,7 @@ function iter(f, q) { var _cell = q.first; while(true) { var cell = _cell; - if (typeof cell !== "object") { + if (typeof cell === "string") { return ; } var next = cell.next; @@ -127,7 +125,7 @@ function fold(f, accu, q) { while(true) { var cell = _cell; var accu$1 = _accu; - if (typeof cell !== "object") { + if (typeof cell === "string") { return accu$1; } var next = cell.next; @@ -143,7 +141,7 @@ function transfer(q1, q2) { return ; } var last = q2.last; - if (typeof last !== "object") { + if (typeof last === "string") { q2.length = q1.length; q2.first = q1.first; q2.last = q1.last; diff --git a/lib/es6/set.js b/lib/es6/set.js index 62b4d3a55c..3b8e7967ae 100644 --- a/lib/es6/set.js +++ b/lib/es6/set.js @@ -6,7 +6,7 @@ import * as Caml_option from "./caml_option.js"; function Make(funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,11 +14,10 @@ function Make(funarg) { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -27,11 +26,11 @@ function Make(funarg) { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -44,7 +43,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -54,15 +53,14 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -75,7 +73,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -85,9 +83,8 @@ function Make(funarg) { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -117,8 +114,7 @@ function Make(funarg) { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -126,25 +122,25 @@ function Make(funarg) { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -159,14 +155,14 @@ function Make(funarg) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -176,11 +172,11 @@ function Make(funarg) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -190,14 +186,14 @@ function Make(funarg) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -207,11 +203,11 @@ function Make(funarg) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -219,7 +215,7 @@ function Make(funarg) { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -227,23 +223,23 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -277,7 +273,7 @@ function Make(funarg) { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -286,7 +282,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -298,7 +294,7 @@ function Make(funarg) { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -306,9 +302,9 @@ function Make(funarg) { var l = t.l; var c = Curry._2(funarg.compare, x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -330,12 +326,12 @@ function Make(funarg) { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -354,10 +350,10 @@ function Make(funarg) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -372,10 +368,10 @@ function Make(funarg) { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -393,11 +389,10 @@ function Make(funarg) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -412,14 +407,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -438,13 +433,13 @@ function Make(funarg) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -459,8 +454,7 @@ function Make(funarg) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -471,8 +465,7 @@ function Make(funarg) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -487,7 +480,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -500,7 +493,7 @@ function Make(funarg) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -511,7 +504,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -527,7 +520,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -541,7 +534,7 @@ function Make(funarg) { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -561,7 +554,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -588,7 +581,7 @@ function Make(funarg) { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -598,7 +591,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -615,7 +608,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -633,7 +626,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -646,7 +639,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -666,7 +659,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -676,7 +669,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -696,7 +689,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -709,7 +702,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -729,7 +722,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -739,7 +732,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -759,7 +752,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -772,7 +765,7 @@ function Make(funarg) { }; }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -823,8 +816,7 @@ function Make(funarg) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -839,10 +831,8 @@ function Make(funarg) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -865,18 +855,15 @@ function Make(funarg) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/setLabels.js b/lib/es6/setLabels.js index 6efa60a772..8c65084ca1 100644 --- a/lib/es6/setLabels.js +++ b/lib/es6/setLabels.js @@ -6,7 +6,7 @@ import * as Caml_option from "./caml_option.js"; function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,11 +14,10 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -27,11 +26,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -44,7 +43,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -54,15 +53,14 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -75,7 +73,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -85,9 +83,8 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -117,8 +114,7 @@ function Make(Ord) { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -126,25 +122,25 @@ function Make(Ord) { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -159,14 +155,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -176,11 +172,11 @@ function Make(Ord) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -190,14 +186,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -207,11 +203,11 @@ function Make(Ord) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -219,7 +215,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -227,32 +223,32 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -286,7 +282,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -295,7 +291,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -307,7 +303,7 @@ function Make(Ord) { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -333,12 +329,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -357,10 +353,10 @@ function Make(Ord) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -375,10 +371,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -396,11 +392,10 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -413,14 +408,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -442,13 +437,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -463,8 +458,7 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -475,8 +469,7 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -491,7 +484,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -504,7 +497,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -515,7 +508,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -531,7 +524,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -545,7 +538,7 @@ function Make(Ord) { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -565,7 +558,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -592,7 +585,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -602,7 +595,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -619,7 +612,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -638,7 +631,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -654,7 +647,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -672,7 +665,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -688,7 +681,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -703,7 +696,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -719,7 +712,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -737,7 +730,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -753,7 +746,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -767,7 +760,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -787,7 +780,7 @@ function Make(Ord) { } }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -813,8 +806,7 @@ function Make(Ord) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -829,10 +821,8 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -855,18 +845,15 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/stream.js b/lib/es6/stream.js index cc68b8e2ac..74b8d71c83 100644 --- a/lib/es6/stream.js +++ b/lib/es6/stream.js @@ -31,7 +31,7 @@ function data(param) { function get_data(count, _d) { while(true) { var d = _d; - if (typeof d !== "object") { + if (typeof d === "string") { return d; } switch (d.TAG) { @@ -40,7 +40,7 @@ function get_data(count, _d) { case "Sapp" : var d2 = d._1; var match = get_data(count, d._0); - if (typeof match !== "object") { + if (typeof match === "string") { _d = d2; continue ; } @@ -102,7 +102,7 @@ function get_data(count, _d) { function peek_data(s) { while(true) { var f = s.data; - if (typeof f !== "object") { + if (typeof f === "string") { return ; } switch (f.TAG) { @@ -110,7 +110,7 @@ function peek_data(s) { return Caml_option.some(f._0); case "Sapp" : var d = get_data(s.count, s.data); - if (typeof d !== "object") { + if (typeof d === "string") { return ; } if (d.TAG === "Scons") { @@ -153,7 +153,7 @@ function peek(s) { function junk_data(s) { while(true) { var g = s.data; - if (typeof g === "object") { + if (typeof g !== "string") { switch (g.TAG) { case "Scons" : s.count = s.count + 1 | 0; @@ -428,7 +428,7 @@ function slazy(f) { } function dump_data(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { console.log("Sempty"); return ; } diff --git a/lib/js/caml_module.js b/lib/js/caml_module.js index 91585755a4..84effc7b1d 100644 --- a/lib/js/caml_module.js +++ b/lib/js/caml_module.js @@ -11,7 +11,7 @@ function init_mod(loc, shape) { }; }; var loop = function (shape, struct_, idx) { - if (typeof shape !== "object") { + if (typeof shape === "string") { switch (shape) { case "Function" : struct_[idx] = undef_module; @@ -56,7 +56,7 @@ function init_mod(loc, shape) { function update_mod(shape, o, n) { var aux = function (shape, o, n, parent, i) { - if (typeof shape !== "object") { + if (typeof shape === "string") { switch (shape) { case "Function" : parent[i] = n; @@ -79,7 +79,7 @@ function update_mod(shape, o, n) { return ; } }; - if (typeof shape !== "object") { + if (typeof shape === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index bdbb33cf5d..3c64e12718 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -92,7 +92,7 @@ function reset(h) { } function copy_bucketlist(param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var key = param.key; @@ -102,19 +102,18 @@ function copy_bucketlist(param) { while(true) { var param = _param; var prec = _prec; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var key = param.key; var data = param.data; var next = param.next; - var r = { - TAG: "Cons", + var r = /* Cons */{ key: key, data: data, next: next }; - if (typeof prec !== "object") { + if (typeof prec === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -131,8 +130,7 @@ function copy_bucketlist(param) { continue ; }; }; - var r = { - TAG: "Cons", + var r = /* Cons */{ key: key, data: data, next: next @@ -168,21 +166,20 @@ function resize(indexfun, h) { var insert_bucket = function (_cell) { while(true) { var cell = _cell; - if (typeof cell !== "object") { + if (typeof cell === "string") { return ; } var key = cell.key; var data = cell.data; var next = cell.next; - var cell$1 = inplace ? cell : ({ - TAG: "Cons", + var cell$1 = inplace ? cell : /* Cons */({ key: key, data: data, next: "Empty" }); var nidx = Curry._2(indexfun, h, key); var tail = Caml_array.get(ndata_tail, nidx); - if (typeof tail !== "object") { + if (typeof tail === "string") { Caml_array.set(ndata, nidx, cell$1); } else { tail.next = cell$1; @@ -200,7 +197,7 @@ function resize(indexfun, h) { } for(var i$1 = 0; i$1 < nsize; ++i$1){ var tail = Caml_array.get(ndata_tail, i$1); - if (typeof tail === "object") { + if (typeof tail !== "string") { tail.next = "Empty"; } @@ -213,8 +210,7 @@ function key_index(h, key) { function add(h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -234,14 +230,14 @@ function remove(h, key) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Caml_obj.equal(k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -256,7 +252,7 @@ function remove(h, key) { function find(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -268,7 +264,7 @@ function find(h, key) { if (Caml_obj.equal(key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -280,7 +276,7 @@ function find(h, key) { if (Caml_obj.equal(key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -295,7 +291,7 @@ function find(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -315,7 +311,7 @@ function find(h, key) { function find_opt(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -324,7 +320,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -333,7 +329,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -345,7 +341,7 @@ function find_opt(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -364,7 +360,7 @@ function find_all(h, key) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -386,7 +382,7 @@ function find_all(h, key) { function replace_bucket(key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -405,8 +401,7 @@ function replace(h, key, data) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -425,7 +420,7 @@ function mem(h, key) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; @@ -442,7 +437,7 @@ function iter(f, h) { var do_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var key = param.key; @@ -481,8 +476,8 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { while(true) { var slot = _slot; var prec = _prec; - if (typeof slot !== "object") { - if (typeof prec !== "object") { + if (typeof slot === "string") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, "Empty"); } else { prec.next = "Empty"; @@ -494,7 +489,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { var next = slot.next; var data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { - if (typeof prec !== "object") { + if (typeof prec === "string") { Caml_array.set(h.data, i, slot); } else { prec.next = slot; @@ -536,7 +531,7 @@ function fold(f, h, init) { while(true) { var accu = _accu; var b = _b; - if (typeof b !== "object") { + if (typeof b === "string") { return accu; } var key = b.key; @@ -575,7 +570,7 @@ function bucket_length(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } var next = param.next; @@ -608,8 +603,7 @@ function MakeSeeded(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -628,14 +622,14 @@ function MakeSeeded(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -649,7 +643,7 @@ function MakeSeeded(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -661,7 +655,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -673,7 +667,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -688,7 +682,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -707,7 +701,7 @@ function MakeSeeded(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -716,7 +710,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -725,7 +719,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -737,7 +731,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -755,7 +749,7 @@ function MakeSeeded(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -776,7 +770,7 @@ function MakeSeeded(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -794,8 +788,7 @@ function MakeSeeded(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -813,7 +806,7 @@ function MakeSeeded(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; @@ -852,8 +845,7 @@ function Make(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = { - TAG: "Cons", + var bucket = /* Cons */{ key: key, data: data, next: Caml_array.get(h.data, i) @@ -872,14 +864,14 @@ function Make(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c !== "object") { + if (typeof c === "string") { return ; } var k = c.key; var next = c.next; if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec !== "object") { + if (typeof prec === "string") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -893,7 +885,7 @@ function Make(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -905,7 +897,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return d1; } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -917,7 +909,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return d2; } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -932,7 +924,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -951,7 +943,7 @@ function Make(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match !== "object") { + if (typeof match === "string") { return ; } var k1 = match.key; @@ -960,7 +952,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 !== "object") { + if (typeof next1 === "string") { return ; } var k2 = next1.key; @@ -969,7 +961,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 !== "object") { + if (typeof next2 === "string") { return ; } var k3 = next2.key; @@ -981,7 +973,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var k = param.key; @@ -999,7 +991,7 @@ function Make(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return /* [] */0; } var k = param.key; @@ -1020,7 +1012,7 @@ function Make(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot !== "object") { + if (typeof slot === "string") { return true; } var k = slot.key; @@ -1038,8 +1030,7 @@ function Make(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, { - TAG: "Cons", + Caml_array.set(h.data, i, /* Cons */{ key: key, data: data, next: l @@ -1057,7 +1048,7 @@ function Make(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var k = param.key; diff --git a/lib/js/map.js b/lib/js/map.js index 3ceda28d16..d8c4fa335c 100644 --- a/lib/js/map.js +++ b/lib/js/map.js @@ -5,7 +5,7 @@ var Caml_option = require("./caml_option.js"); function Make(funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function Make(funarg) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -24,8 +23,7 @@ function Make(funarg) { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -35,11 +33,11 @@ function Make(funarg) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -53,7 +51,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -63,8 +61,7 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -72,7 +69,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +83,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -96,16 +93,15 @@ function Make(funarg) { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -122,8 +118,7 @@ function Make(funarg) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -150,7 +145,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -167,7 +162,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -182,7 +177,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -206,7 +201,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -218,7 +213,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -242,7 +237,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -257,7 +252,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -281,7 +276,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -293,7 +288,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return [ v0, d0 @@ -317,7 +312,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -331,7 +326,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -345,14 +340,14 @@ function Make(funarg) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -365,11 +360,11 @@ function Make(funarg) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -382,14 +377,14 @@ function Make(funarg) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -402,11 +397,11 @@ function Make(funarg) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -417,7 +412,7 @@ function Make(funarg) { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -425,24 +420,24 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -469,11 +464,10 @@ function Make(funarg) { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -498,8 +492,7 @@ function Make(funarg) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -526,7 +519,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -536,14 +529,13 @@ function Make(funarg) { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -552,15 +544,14 @@ function Make(funarg) { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -572,7 +563,7 @@ function Make(funarg) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -583,7 +574,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -599,7 +590,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -613,25 +604,25 @@ function Make(funarg) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -644,10 +635,10 @@ function Make(funarg) { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -661,7 +652,7 @@ function Make(funarg) { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -696,8 +687,8 @@ function Make(funarg) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -709,7 +700,7 @@ function Make(funarg) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -725,12 +716,12 @@ function Make(funarg) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -757,7 +748,7 @@ function Make(funarg) { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -778,7 +769,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -809,11 +800,10 @@ function Make(funarg) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -829,14 +819,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -858,14 +848,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -880,7 +870,7 @@ function Make(funarg) { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -890,7 +880,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/lib/js/mapLabels.js b/lib/js/mapLabels.js index 79d4163c8f..77f0473a55 100644 --- a/lib/js/mapLabels.js +++ b/lib/js/mapLabels.js @@ -5,7 +5,7 @@ var Caml_option = require("./caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,8 +14,7 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -24,8 +23,7 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -35,11 +33,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -53,7 +51,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -63,8 +61,7 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -72,7 +69,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +83,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -96,16 +93,15 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -122,8 +118,7 @@ function Make(Ord) { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -150,7 +145,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -169,7 +164,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -189,7 +184,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -208,7 +203,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -228,7 +223,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -244,7 +239,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -264,7 +259,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -283,7 +278,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -303,7 +298,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -317,7 +312,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(Ord.compare, x, param.v); @@ -331,7 +326,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -345,14 +340,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -365,11 +360,11 @@ function Make(Ord) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -382,14 +377,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -402,11 +397,11 @@ function Make(Ord) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -417,7 +412,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -425,24 +420,24 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -469,11 +464,10 @@ function Make(Ord) { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -498,8 +492,7 @@ function Make(Ord) { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -526,7 +519,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -536,14 +529,13 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -552,15 +544,14 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -572,7 +563,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -583,7 +574,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -599,7 +590,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -613,25 +604,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -644,10 +635,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -661,7 +652,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -696,8 +687,8 @@ function Make(Ord) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -709,7 +700,7 @@ function Make(Ord) { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -725,12 +716,12 @@ function Make(Ord) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -757,7 +748,7 @@ function Make(Ord) { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -778,7 +769,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -809,11 +800,10 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -829,14 +819,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -858,14 +848,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -880,7 +870,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -890,7 +880,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; diff --git a/lib/js/moreLabels.js b/lib/js/moreLabels.js index 46d1a17ee2..038e6624af 100644 --- a/lib/js/moreLabels.js +++ b/lib/js/moreLabels.js @@ -35,7 +35,7 @@ var Hashtbl = { var $$Map = { Make: (function (funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -44,8 +44,7 @@ var $$Map = { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -54,8 +53,7 @@ var $$Map = { }; }; var singleton = function (x, d) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: d, @@ -65,11 +63,11 @@ var $$Map = { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +81,7 @@ var $$Map = { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -93,8 +91,7 @@ var $$Map = { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: d, @@ -102,7 +99,7 @@ var $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -116,7 +113,7 @@ var $$Map = { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -126,16 +123,15 @@ var $$Map = { }; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m !== "object") { - return { - TAG: "Node", + if (typeof m === "string") { + return /* Node */{ l: "Empty", v: x, d: data, @@ -152,8 +148,7 @@ var $$Map = { if (d === data) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data, @@ -180,7 +175,7 @@ var $$Map = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -199,7 +194,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -219,7 +214,7 @@ var $$Map = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -238,7 +233,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -258,7 +253,7 @@ var $$Map = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -274,7 +269,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -294,7 +289,7 @@ var $$Map = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -313,7 +308,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return [ v0, d0 @@ -333,7 +328,7 @@ var $$Map = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -347,7 +342,7 @@ var $$Map = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -361,7 +356,7 @@ var $$Map = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -375,14 +370,14 @@ var $$Map = { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -395,11 +390,11 @@ var $$Map = { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return [ param.v, param.d @@ -412,14 +407,14 @@ var $$Map = { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -432,11 +427,11 @@ var $$Map = { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return [ param.v, param.d @@ -447,7 +442,7 @@ var $$Map = { }; }; var remove_min_binding = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -455,24 +450,24 @@ var $$Map = { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -499,11 +494,10 @@ var $$Map = { } }; var update = function (x, f, m) { - if (typeof m !== "object") { + if (typeof m === "string") { var data = Curry._1(f, undefined); if (data !== undefined) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -528,8 +522,7 @@ var $$Map = { if (d === data$2) { return m; } else { - return { - TAG: "Node", + return /* Node */{ l: l, v: x, d: data$2, @@ -556,7 +549,7 @@ var $$Map = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -566,14 +559,13 @@ var $$Map = { }; }; var map = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: param.v, d: d$p, @@ -582,15 +574,14 @@ var $$Map = { }; }; var mapi = function (f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return "Empty"; } var v = param.v; var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return { - TAG: "Node", + return /* Node */{ l: l$p, v: v, d: d$p, @@ -602,7 +593,7 @@ var $$Map = { while(true) { var accu = _accu; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -613,7 +604,7 @@ var $$Map = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -629,7 +620,7 @@ var $$Map = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -643,25 +634,25 @@ var $$Map = { }; }; var add_min_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_binding(v, d, l); } var rh = r.h; @@ -674,10 +665,10 @@ var $$Map = { } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; } - if (typeof t2 !== "object") { + if (typeof t2 === "string") { return t1; } var match = min_binding(t2); @@ -691,7 +682,7 @@ var $$Map = { } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", undefined, @@ -726,8 +717,8 @@ var $$Map = { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { + if (typeof s1 === "string") { + if (typeof s2 === "string") { return "Empty"; } @@ -739,7 +730,7 @@ var $$Map = { } } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -755,12 +746,12 @@ var $$Map = { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var d2 = s2.d; @@ -787,7 +778,7 @@ var $$Map = { } }; var filter = function (p, m) { - if (typeof m !== "object") { + if (typeof m === "string") { return "Empty"; } var r = m.r; @@ -808,7 +799,7 @@ var $$Map = { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -839,11 +830,10 @@ var $$Map = { while(true) { var e = _e; var m = _m; - if (typeof m !== "object") { + if (typeof m === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: m.v, _1: m.d, _2: m.r, @@ -859,14 +849,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -888,14 +878,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return true; } else { return false; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -910,7 +900,7 @@ var $$Map = { }; }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -920,7 +910,7 @@ var $$Map = { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -979,7 +969,7 @@ var $$Map = { var $$Set = { Make: (function (funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -987,11 +977,10 @@ var $$Set = { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -1000,11 +989,11 @@ var $$Set = { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1017,7 +1006,7 @@ var $$Set = { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -1027,15 +1016,14 @@ var $$Set = { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1048,7 +1036,7 @@ var $$Set = { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -1058,9 +1046,8 @@ var $$Set = { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -1090,8 +1077,7 @@ var $$Set = { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -1099,25 +1085,25 @@ var $$Set = { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -1132,14 +1118,14 @@ var $$Set = { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -1149,11 +1135,11 @@ var $$Set = { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -1163,14 +1149,14 @@ var $$Set = { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -1180,11 +1166,11 @@ var $$Set = { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -1192,7 +1178,7 @@ var $$Set = { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -1200,32 +1186,32 @@ var $$Set = { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -1259,7 +1245,7 @@ var $$Set = { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -1268,7 +1254,7 @@ var $$Set = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -1280,7 +1266,7 @@ var $$Set = { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1306,12 +1292,12 @@ var $$Set = { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -1330,10 +1316,10 @@ var $$Set = { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -1348,10 +1334,10 @@ var $$Set = { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -1369,11 +1355,10 @@ var $$Set = { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -1386,14 +1371,14 @@ var $$Set = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -1415,13 +1400,13 @@ var $$Set = { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -1436,8 +1421,7 @@ var $$Set = { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -1448,8 +1432,7 @@ var $$Set = { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -1464,7 +1447,7 @@ var $$Set = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -1477,7 +1460,7 @@ var $$Set = { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -1488,7 +1471,7 @@ var $$Set = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -1504,7 +1487,7 @@ var $$Set = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -1518,7 +1501,7 @@ var $$Set = { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1538,7 +1521,7 @@ var $$Set = { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -1565,7 +1548,7 @@ var $$Set = { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1575,7 +1558,7 @@ var $$Set = { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -1592,7 +1575,7 @@ var $$Set = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1611,7 +1594,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -1627,7 +1610,7 @@ var $$Set = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1645,7 +1628,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -1661,7 +1644,7 @@ var $$Set = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1676,7 +1659,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -1692,7 +1675,7 @@ var $$Set = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1710,7 +1693,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -1726,7 +1709,7 @@ var $$Set = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1740,7 +1723,7 @@ var $$Set = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -1760,7 +1743,7 @@ var $$Set = { } }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -1786,8 +1769,7 @@ var $$Set = { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1802,10 +1784,8 @@ var $$Set = { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -1828,18 +1808,15 @@ var $$Set = { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/queue.js b/lib/js/queue.js index 3fb8d780f0..8518ba0e0e 100644 --- a/lib/js/queue.js +++ b/lib/js/queue.js @@ -20,13 +20,12 @@ function clear(q) { } function add(x, q) { - var cell = { - TAG: "Cons", + var cell = /* Cons */{ content: x, next: "Nil" }; var last = q.last; - if (typeof last !== "object") { + if (typeof last === "string") { q.length = 1; q.first = cell; q.last = cell; @@ -39,7 +38,7 @@ function add(x, q) { function peek(q) { var match = q.first; - if (typeof match === "object") { + if (typeof match !== "string") { return match.content; } throw { @@ -50,7 +49,7 @@ function peek(q) { function take(q) { var match = q.first; - if (typeof match !== "object") { + if (typeof match === "string") { throw { RE_EXN_ID: Empty, Error: new Error() @@ -58,7 +57,7 @@ function take(q) { } var content = match.content; var next = match.next; - if (typeof next !== "object") { + if (typeof next === "string") { clear(q); return content; } @@ -78,17 +77,16 @@ function copy(q) { while(true) { var cell = _cell; var prev = _prev; - if (typeof cell !== "object") { + if (typeof cell === "string") { q_res.last = prev; return q_res; } var next = cell.next; - var res = { - TAG: "Cons", + var res = /* Cons */{ content: cell.content, next: "Nil" }; - if (typeof prev !== "object") { + if (typeof prev === "string") { q_res.first = res; } else { prev.next = res; @@ -111,7 +109,7 @@ function iter(f, q) { var _cell = q.first; while(true) { var cell = _cell; - if (typeof cell !== "object") { + if (typeof cell === "string") { return ; } var next = cell.next; @@ -127,7 +125,7 @@ function fold(f, accu, q) { while(true) { var cell = _cell; var accu$1 = _accu; - if (typeof cell !== "object") { + if (typeof cell === "string") { return accu$1; } var next = cell.next; @@ -143,7 +141,7 @@ function transfer(q1, q2) { return ; } var last = q2.last; - if (typeof last !== "object") { + if (typeof last === "string") { q2.length = q1.length; q2.first = q1.first; q2.last = q1.last; diff --git a/lib/js/set.js b/lib/js/set.js index 27847c6ad0..6c4e61d394 100644 --- a/lib/js/set.js +++ b/lib/js/set.js @@ -6,7 +6,7 @@ var Caml_option = require("./caml_option.js"); function Make(funarg) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,11 +14,10 @@ function Make(funarg) { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -27,11 +26,11 @@ function Make(funarg) { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -44,7 +43,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -54,15 +53,14 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -75,7 +73,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -85,9 +83,8 @@ function Make(funarg) { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -117,8 +114,7 @@ function Make(funarg) { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -126,25 +122,25 @@ function Make(funarg) { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -159,14 +155,14 @@ function Make(funarg) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -176,11 +172,11 @@ function Make(funarg) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -190,14 +186,14 @@ function Make(funarg) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -207,11 +203,11 @@ function Make(funarg) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -219,7 +215,7 @@ function Make(funarg) { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -227,23 +223,23 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -277,7 +273,7 @@ function Make(funarg) { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -286,7 +282,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -298,7 +294,7 @@ function Make(funarg) { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -306,9 +302,9 @@ function Make(funarg) { var l = t.l; var c = Curry._2(funarg.compare, x, v); if (c === 0) { - if (typeof l !== "object") { + if (typeof l === "string") { return r; - } else if (typeof r !== "object") { + } else if (typeof r === "string") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -330,12 +326,12 @@ function Make(funarg) { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -354,10 +350,10 @@ function Make(funarg) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -372,10 +368,10 @@ function Make(funarg) { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -393,11 +389,10 @@ function Make(funarg) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -412,14 +407,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -438,13 +433,13 @@ function Make(funarg) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -459,8 +454,7 @@ function Make(funarg) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -471,8 +465,7 @@ function Make(funarg) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -487,7 +480,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -500,7 +493,7 @@ function Make(funarg) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -511,7 +504,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -527,7 +520,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -541,7 +534,7 @@ function Make(funarg) { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -561,7 +554,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -588,7 +581,7 @@ function Make(funarg) { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -598,7 +591,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -615,7 +608,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -633,7 +626,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -646,7 +639,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -666,7 +659,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -676,7 +669,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -696,7 +689,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -709,7 +702,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return v0; } var v$1 = param$1.v; @@ -729,7 +722,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -739,7 +732,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 !== "object") { + if (typeof param$1 === "string") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -759,7 +752,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -772,7 +765,7 @@ function Make(funarg) { }; }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -823,8 +816,7 @@ function Make(funarg) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -839,10 +831,8 @@ function Make(funarg) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -865,18 +855,15 @@ function Make(funarg) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/setLabels.js b/lib/js/setLabels.js index e7f53c9a7e..a3addb80bf 100644 --- a/lib/js/setLabels.js +++ b/lib/js/setLabels.js @@ -6,7 +6,7 @@ var Caml_option = require("./caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return param.h; @@ -14,11 +14,10 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; - return { - TAG: "Node", + hr = typeof r === "string" ? 0 : r.h; + return /* Node */{ l: l, v: v, r: r, @@ -27,11 +26,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l !== "object" ? 0 : l.h; + hl = typeof l === "string" ? 0 : l.h; var hr; - hr = typeof r !== "object" ? 0 : r.h; + hr = typeof r === "string" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { + if (typeof l === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -44,7 +43,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr === "object") { + if (typeof lr !== "string") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -54,15 +53,14 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", + return /* Node */{ l: l, v: v, r: r, h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r !== "object") { + if (typeof r === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -75,7 +73,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl === "object") { + if (typeof rl !== "string") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -85,9 +83,8 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t !== "object") { - return { - TAG: "Node", + if (typeof t === "string") { + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -117,8 +114,7 @@ function Make(Ord) { } }; var singleton = function (x) { - return { - TAG: "Node", + return /* Node */{ l: "Empty", v: x, r: "Empty", @@ -126,25 +122,25 @@ function Make(Ord) { }; }; var add_min_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l !== "object") { + if (typeof l === "string") { return add_min_element(v, r); } var lh = l.h; - if (typeof r !== "object") { + if (typeof r === "string") { return add_max_element(v, l); } var rh = r.h; @@ -159,14 +155,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.v; } _param = l; @@ -176,11 +172,11 @@ function Make(Ord) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return Caml_option.some(param.v); } _param = l; @@ -190,14 +186,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return param.v; } _param = r; @@ -207,11 +203,11 @@ function Make(Ord) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var r = param.r; - if (typeof r !== "object") { + if (typeof r === "string") { return Caml_option.some(param.v); } _param = r; @@ -219,7 +215,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -227,32 +223,32 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l !== "object") { + if (typeof l === "string") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 !== "object") { + if (typeof t1 === "string") { return t2; - } else if (typeof t2 !== "object") { + } else if (typeof t2 === "string") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", false, @@ -286,7 +282,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return true; } else { return false; @@ -295,7 +291,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -307,7 +303,7 @@ function Make(Ord) { }; }; var remove = function (x, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -333,12 +329,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var h2 = s2.h; @@ -357,10 +353,10 @@ function Make(Ord) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return "Empty"; } var r1 = s1.r; @@ -375,10 +371,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return "Empty"; } - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return s1; } var r1 = s1.r; @@ -396,11 +392,10 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return e; } - _e = { - TAG: "More", + _e = /* More */{ _0: s.v, _1: s.r, _2: e @@ -413,14 +408,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { + if (typeof e1 === "string") { + if (typeof e2 === "string") { return 0; } else { return -1; } } - if (typeof e2 !== "object") { + if (typeof e2 === "string") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -442,13 +437,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 !== "object") { + if (typeof s1 === "string") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 !== "object") { + if (typeof s2 === "string") { return false; } var r2 = s2.r; @@ -463,8 +458,7 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: l1, v: v1, r: "Empty", @@ -475,8 +469,7 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset({ - TAG: "Node", + if (!subset(/* Node */{ l: "Empty", v: v1, r: r1, @@ -491,7 +484,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } iter(f, param.l); @@ -504,7 +497,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s !== "object") { + if (typeof s === "string") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -515,7 +508,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return true; } if (!Curry._1(p, param.v)) { @@ -531,7 +524,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return false; } if (Curry._1(p, param.v)) { @@ -545,7 +538,7 @@ function Make(Ord) { }; }; var filter = function (p, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -565,7 +558,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param !== "object") { + if (typeof param === "string") { return [ "Empty", "Empty" @@ -592,7 +585,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param !== "object") { + if (typeof param === "string") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -602,7 +595,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param !== "object") { + if (typeof param === "string") { return accu; } _param = param.l; @@ -619,7 +612,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -638,7 +631,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -654,7 +647,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -672,7 +665,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -688,7 +681,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -703,7 +696,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return v0; } var v = param.v; @@ -719,7 +712,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -737,7 +730,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param !== "object") { + if (typeof param === "string") { return Caml_option.some(v0); } var v = param.v; @@ -753,7 +746,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -767,7 +760,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param !== "object") { + if (typeof param === "string") { return ; } var v = param.v; @@ -787,7 +780,7 @@ function Make(Ord) { } }; var map = function (f, t) { - if (typeof t !== "object") { + if (typeof t === "string") { return "Empty"; } var r = t.r; @@ -813,8 +806,7 @@ function Make(Ord) { case 1 : if (l) { return [ - { - TAG: "Node", + /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -829,10 +821,8 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", @@ -855,18 +845,15 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - { - TAG: "Node", - l: { - TAG: "Node", + /* Node */{ + l: /* Node */{ l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: { - TAG: "Node", + r: /* Node */{ l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/stream.js b/lib/js/stream.js index 3c564319c9..421e3288f2 100644 --- a/lib/js/stream.js +++ b/lib/js/stream.js @@ -31,7 +31,7 @@ function data(param) { function get_data(count, _d) { while(true) { var d = _d; - if (typeof d !== "object") { + if (typeof d === "string") { return d; } switch (d.TAG) { @@ -40,7 +40,7 @@ function get_data(count, _d) { case "Sapp" : var d2 = d._1; var match = get_data(count, d._0); - if (typeof match !== "object") { + if (typeof match === "string") { _d = d2; continue ; } @@ -102,7 +102,7 @@ function get_data(count, _d) { function peek_data(s) { while(true) { var f = s.data; - if (typeof f !== "object") { + if (typeof f === "string") { return ; } switch (f.TAG) { @@ -110,7 +110,7 @@ function peek_data(s) { return Caml_option.some(f._0); case "Sapp" : var d = get_data(s.count, s.data); - if (typeof d !== "object") { + if (typeof d === "string") { return ; } if (d.TAG === "Scons") { @@ -153,7 +153,7 @@ function peek(s) { function junk_data(s) { while(true) { var g = s.data; - if (typeof g === "object") { + if (typeof g !== "string") { switch (g.TAG) { case "Scons" : s.count = s.count + 1 | 0; @@ -428,7 +428,7 @@ function slazy(f) { } function dump_data(f, param) { - if (typeof param !== "object") { + if (typeof param === "string") { console.log("Sempty"); return ; } From 78827c57d990eed2dedff3e5a1b6af2bb3c74357 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 21 Mar 2023 11:45:41 +0100 Subject: [PATCH 02/13] Allow more general type for tags. Compile is_tag to `!== "object"` instead of `=== "string"`. --- jscomp/test/adt_optimize_test.js | 14 +- jscomp/test/bal_set_mini.js | 28 +- jscomp/test/bdd.js | 18 +- jscomp/test/defunctor_make_test.js | 16 +- jscomp/test/demo_int_map.js | 18 +- jscomp/test/demo_page.js | 2 +- jscomp/test/flexible_array_test.js | 14 +- jscomp/test/flow_parser_reg_test.js | 400 +++++++++---------- jscomp/test/fun_pattern_match.js | 8 +- jscomp/test/gpr_1658_test.js | 2 +- jscomp/test/gpr_3209_test.js | 2 +- jscomp/test/gpr_3609_test.js | 2 +- jscomp/test/gpr_4900_test.js | 2 +- jscomp/test/gpr_4924_test.js | 14 +- jscomp/test/gpr_5280_optimize_test.js | 2 +- jscomp/test/inline_map2_test.js | 282 ++++++------- jscomp/test/inline_map_demo.js | 18 +- jscomp/test/inline_map_test.js | 18 +- jscomp/test/inline_record_test.js | 2 +- jscomp/test/int_map.js | 126 +++--- jscomp/test/js_json_test.js | 42 +- jscomp/test/large_record_duplication_test.js | 4 +- jscomp/test/map_find_test.js | 36 +- jscomp/test/map_test.js | 50 +-- jscomp/test/mario_game.js | 12 +- jscomp/test/ocaml_re_test.js | 124 +++--- jscomp/test/offset.js | 126 +++--- jscomp/test/option_repr_test.js | 2 +- jscomp/test/pq_test.js | 10 +- jscomp/test/rbset.js | 64 +-- jscomp/test/rec_module_test.js | 126 +++--- jscomp/test/record_extension_test.js | 4 +- jscomp/test/recursive_records_test.js | 4 +- jscomp/test/set_gen.js | 76 ++-- jscomp/test/string_set.js | 26 +- jscomp/test/test_demo.js | 2 +- jscomp/test/test_fib.js | 4 +- jscomp/test/test_for_map.js | 126 +++--- jscomp/test/test_int_map_find.js | 16 +- jscomp/test/test_set.js | 98 ++--- jscomp/test/test_string_map.js | 18 +- jscomp/test/test_switch.js | 2 +- jscomp/test/test_trywith.js | 2 +- jscomp/test/ticker.js | 144 +++---- jscomp/test/topsort_test.js | 126 +++--- jscomp/test/typeof_test.js | 2 +- jscomp/test/utf8_decode_test.js | 8 +- jscomp/test/variant.js | 6 +- jscomp/test/variantsMatching.js | 12 +- lib/es6/caml_module.js | 6 +- lib/es6/hashtbl.js | 102 ++--- lib/es6/map.js | 126 +++--- lib/es6/mapLabels.js | 126 +++--- lib/es6/moreLabels.js | 252 ++++++------ lib/es6/queue.js | 18 +- lib/es6/set.js | 126 +++--- lib/es6/setLabels.js | 126 +++--- lib/es6/stream.js | 12 +- lib/js/caml_module.js | 6 +- lib/js/hashtbl.js | 102 ++--- lib/js/map.js | 126 +++--- lib/js/mapLabels.js | 126 +++--- lib/js/moreLabels.js | 252 ++++++------ lib/js/queue.js | 18 +- lib/js/set.js | 126 +++--- lib/js/setLabels.js | 126 +++--- lib/js/stream.js | 12 +- 67 files changed, 2024 insertions(+), 2024 deletions(-) diff --git a/jscomp/test/adt_optimize_test.js b/jscomp/test/adt_optimize_test.js index f42842fbb5..3e2ef4f589 100644 --- a/jscomp/test/adt_optimize_test.js +++ b/jscomp/test/adt_optimize_test.js @@ -61,7 +61,7 @@ function f4(param) { } function f5(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "A" : return 1; @@ -84,7 +84,7 @@ function f5(param) { } function f6(param) { - if (typeof param !== "string") { + if (typeof param === "object") { return 1; } switch (param) { @@ -98,7 +98,7 @@ function f6(param) { } function f7(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "A" : return 1; @@ -122,7 +122,7 @@ function f7(param) { } function f8(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "T60" : case "T61" : @@ -142,7 +142,7 @@ function f8(param) { } function f9(param) { - if (typeof param === "string") { + if (typeof param !== "object") { if (param === "T63") { return 3; } else { @@ -161,7 +161,7 @@ function f9(param) { } function f10(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "T60" : return 0; @@ -187,7 +187,7 @@ function f10(param) { } function f11(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return 2; } if (x.TAG === "D") { diff --git a/jscomp/test/bal_set_mini.js b/jscomp/test/bal_set_mini.js index d329e9f154..1ed48609a3 100644 --- a/jscomp/test/bal_set_mini.js +++ b/jscomp/test/bal_set_mini.js @@ -2,7 +2,7 @@ function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._3; @@ -24,7 +24,7 @@ function bal(l, v, r) { var hl = height(l); var hr = height(r); if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { return "Empty"; } var lr = l._2; @@ -32,7 +32,7 @@ function bal(l, v, r) { var ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); - } else if (typeof lr === "string") { + } else if (typeof lr !== "object") { return "Empty"; } else { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); @@ -46,7 +46,7 @@ function bal(l, v, r) { _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { return "Empty"; } var rr = r._2; @@ -54,7 +54,7 @@ function bal(l, v, r) { var rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); - } else if (typeof rl === "string") { + } else if (typeof rl !== "object") { return "Empty"; } else { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); @@ -72,7 +72,7 @@ function compare_int(x, y) { } function add(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -97,11 +97,11 @@ function min_elt(_def, _param) { while(true) { var param = _param; var def = _def; - if (typeof param === "string") { + if (typeof param !== "object") { return def; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._1; } _param = l; @@ -111,7 +111,7 @@ function min_elt(_def, _param) { } function remove_min_elt(l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; } else { return bal(remove_min_elt(l._0, l._1, l._2), v, r); @@ -119,10 +119,10 @@ function remove_min_elt(l, v, r) { } function internal_merge(l, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; } - if (typeof r === "string") { + if (typeof r !== "object") { return l; } var rv = r._1; @@ -130,7 +130,7 @@ function internal_merge(l, r) { } function remove(x, tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return "Empty"; } var r = tree._2; @@ -149,7 +149,7 @@ function remove(x, tree) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = compare_int(x, param._1); @@ -180,7 +180,7 @@ for(var i$2 = 0; i$2 <= 100000; ++i$2){ var match = v; -if (typeof match !== "string") { +if (typeof match === "object") { console.log("impossible"); } diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index aaef425f01..666336ecf3 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -5,7 +5,7 @@ var Caml_array = require("../../lib/js/caml_array.js"); function $$eval(_bdd, vars) { while(true) { var bdd = _bdd; - if (typeof bdd === "string") { + if (typeof bdd !== "object") { if (bdd === "One") { return true; } else { @@ -22,7 +22,7 @@ function $$eval(_bdd, vars) { } function getId(bdd) { - if (typeof bdd === "string") { + if (typeof bdd !== "object") { if (bdd === "One") { return 1; } else { @@ -64,7 +64,7 @@ function resize(newSize) { return ; } var n = bucket.hd; - if (typeof n === "string") { + if (typeof n !== "object") { if (n === "One") { throw { RE_EXN_ID: "Assert_failure", @@ -140,7 +140,7 @@ function mkNode(low, v, high) { var b = _b; if (b) { var n = b.hd; - if (typeof n === "string") { + if (typeof n !== "object") { if (n === "One") { throw { RE_EXN_ID: "Assert_failure", @@ -217,7 +217,7 @@ function hash(x, y) { } function not(n) { - if (typeof n === "string") { + if (typeof n !== "object") { if (n === "One") { return "Zero"; } else { @@ -236,7 +236,7 @@ function not(n) { } function and2(n1, n2) { - if (typeof n1 === "string") { + if (typeof n1 !== "object") { if (n1 === "One") { return n2; } else { @@ -247,7 +247,7 @@ function and2(n1, n2) { var i1 = n1._2; var v1 = n1._1; var l1 = n1._0; - if (typeof n2 === "string") { + if (typeof n2 !== "object") { if (n2 === "One") { return n1; } else { @@ -283,7 +283,7 @@ function and2(n1, n2) { } function xor(n1, n2) { - if (typeof n1 === "string") { + if (typeof n1 !== "object") { if (n1 === "One") { return not(n2); } else { @@ -294,7 +294,7 @@ function xor(n1, n2) { var i1 = n1._2; var v1 = n1._1; var l1 = n1._0; - if (typeof n2 === "string") { + if (typeof n2 !== "object") { if (n2 === "One") { return not(n1); } else { diff --git a/jscomp/test/defunctor_make_test.js b/jscomp/test/defunctor_make_test.js index 9d50a32496..bf3aa8c376 100644 --- a/jscomp/test/defunctor_make_test.js +++ b/jscomp/test/defunctor_make_test.js @@ -16,7 +16,7 @@ var Comparable = { }; function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._4; @@ -37,11 +37,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -55,7 +55,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -73,7 +73,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -87,7 +87,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -98,7 +98,7 @@ function bal(l, x, d, r) { } function add(x, data, compare, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return /* Node */{ _0: "Empty", _1: x, diff --git a/jscomp/test/demo_int_map.js b/jscomp/test/demo_int_map.js index 4e5e534d68..1a2107a405 100644 --- a/jscomp/test/demo_int_map.js +++ b/jscomp/test/demo_int_map.js @@ -2,7 +2,7 @@ function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -23,11 +23,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -41,7 +41,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -59,7 +59,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -73,7 +73,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -84,7 +84,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -130,7 +130,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 2b55d2649d..56b50b2693 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -21,7 +21,7 @@ function sum(n) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Nil"; } else { return /* Cons */{ diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index 1f727340c7..30d40d89fc 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -9,7 +9,7 @@ function sub(_tr, _k) { while(true) { var k = _k; var tr = _tr; - if (typeof tr === "string") { + if (typeof tr !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -30,7 +30,7 @@ function sub(_tr, _k) { } function update(tr, k, w) { - if (typeof tr === "string") { + if (typeof tr !== "object") { if (k === 1) { return /* Br */{ _0: w, @@ -69,7 +69,7 @@ function update(tr, k, w) { } function $$delete(tr, n) { - if (typeof tr === "string") { + if (typeof tr !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -97,7 +97,7 @@ function $$delete(tr, n) { } function loext(tr, w) { - if (typeof tr === "string") { + if (typeof tr !== "object") { return /* Br */{ _0: w, _1: "Lf", @@ -113,14 +113,14 @@ function loext(tr, w) { } function lorem(tr) { - if (typeof tr === "string") { + if (typeof tr !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = tr._1; - if (typeof l !== "string") { + if (typeof l === "object") { return /* Br */{ _0: l._0, _1: tr._2, @@ -128,7 +128,7 @@ function lorem(tr) { }; } var tmp = tr._2; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return "Lf"; } throw { diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 8f42086840..fd2223b806 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -84,7 +84,7 @@ function btwn_exclusive(loc1, loc2) { } function string_of_filename(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "(global)"; } else { return param._0; @@ -92,7 +92,7 @@ function string_of_filename(param) { } function order_of_filename(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 1; } switch (param.TAG) { @@ -1500,7 +1500,7 @@ Caml_module.update_mod({ }, Class, Class); function token_to_string(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "T_IDENTIFIER" : return "T_IDENTIFIER"; @@ -1824,7 +1824,7 @@ function get_result_and_clear_state(param) { var env = match[0]; var match$1; var exit = 0; - if (typeof lex_token === "string") { + if (typeof lex_token !== "object") { exit = 2; } else { switch (lex_token.TAG) { @@ -5271,7 +5271,7 @@ function token$1(env) { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -5280,9 +5280,9 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -5293,11 +5293,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -5310,7 +5310,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -5327,7 +5327,7 @@ function bal(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -5340,7 +5340,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -5351,7 +5351,7 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -5385,7 +5385,7 @@ function add(x, t) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.string_compare(x, param.v); @@ -5520,7 +5520,7 @@ function init_env(token_sinkOpt, parse_optionsOpt, source, content) { var token_sink = token_sinkOpt !== undefined ? Caml_option.valFromOption(token_sinkOpt) : undefined; var parse_options = parse_optionsOpt !== undefined ? Caml_option.valFromOption(parse_optionsOpt) : undefined; var lb = Lexing.from_string(content); - if (source !== undefined && typeof source !== "string") { + if (source !== undefined && typeof source === "object") { var init = lb.lex_curr_p; lb.lex_curr_p = { pos_fname: source._0, @@ -5823,7 +5823,7 @@ function is_line_terminator(env) { function is_implicit_semicolon(env) { var match = token$2(undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return is_line_terminator(env); } switch (match) { @@ -5852,7 +5852,7 @@ function is_identifier(iOpt, env) { if (is_strict_reserved(name) || is_restricted(name) || is_future_reserved(name)) { return true; } - if (typeof match !== "string") { + if (typeof match === "object") { return false; } switch (match) { @@ -5883,7 +5883,7 @@ function is_function(iOpt, env) { function is_class(iOpt, env) { var i = iOpt !== undefined ? iOpt : 0; var match = token$2(i, env); - if (typeof match !== "string") { + if (typeof match === "object") { return false; } switch (match) { @@ -5905,7 +5905,7 @@ function error(env, e) { function get_unexpected_error(param) { var tmp = param[0]; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { switch (tmp) { case "T_IDENTIFIER" : return "UnexpectedIdentifier"; @@ -6171,7 +6171,7 @@ var Parser_env_Try = { }; function height$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -6180,9 +6180,9 @@ function height$1(param) { function create$2(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -6193,11 +6193,11 @@ function create$2(l, v, r) { function bal$1(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6210,7 +6210,7 @@ function bal$1(l, v, r) { if (height$1(ll) >= height$1(lr)) { return create$2(ll, lv, create$2(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$2(create$2(ll, lv, lr.l), lr.v, create$2(lr.r, v, r)); } throw { @@ -6227,7 +6227,7 @@ function bal$1(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6240,7 +6240,7 @@ function bal$1(l, v, r) { if (height$1(rr) >= height$1(rl)) { return create$2(create$2(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$2(create$2(l, v, rl.l), rl.v, create$2(rl.r, rv, rr)); } throw { @@ -6251,7 +6251,7 @@ function bal$1(l, v, r) { } function add$1(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -6285,7 +6285,7 @@ function add$1(x, t) { function mem$1(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.string_compare(x, param.v); @@ -6298,7 +6298,7 @@ function mem$1(x, _param) { } function height$2(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -6319,11 +6319,11 @@ function create$3(l, x, d, r) { function bal$2(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -6337,7 +6337,7 @@ function bal$2(l, x, d, r) { if (height$2(ll) >= height$2(lr)) { return create$3(ll, lv, ld, create$3(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$3(create$3(ll, lv, ld, lr.l), lr.v, lr.d, create$3(lr.r, x, d, r)); } throw { @@ -6355,7 +6355,7 @@ function bal$2(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -6369,7 +6369,7 @@ function bal$2(l, x, d, r) { if (height$2(rr) >= height$2(rl)) { return create$3(create$3(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$3(create$3(l, x, d, rl.l), rl.v, rl.d, create$3(rl.r, rv, rd, rr)); } throw { @@ -6380,7 +6380,7 @@ function bal$2(l, x, d, r) { } function add$2(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -6426,7 +6426,7 @@ function add$2(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -6451,7 +6451,7 @@ function compare$1(param, param$1) { } function height$3(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -6460,9 +6460,9 @@ function height$3(param) { function create$4(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -6473,11 +6473,11 @@ function create$4(l, v, r) { function bal$3(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6490,7 +6490,7 @@ function bal$3(l, v, r) { if (height$3(ll) >= height$3(lr)) { return create$4(ll, lv, create$4(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$4(create$4(ll, lv, lr.l), lr.v, create$4(lr.r, v, r)); } throw { @@ -6507,7 +6507,7 @@ function bal$3(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -6520,7 +6520,7 @@ function bal$3(l, v, r) { if (height$3(rr) >= height$3(rl)) { return create$4(create$4(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$4(create$4(l, v, rl.l), rl.v, create$4(rl.r, rv, rr)); } throw { @@ -6531,7 +6531,7 @@ function bal$3(l, v, r) { } function add$3(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -6565,7 +6565,7 @@ function add$3(x, t) { function mem$2(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = compare$1(x, param.v); @@ -6730,7 +6730,7 @@ function param_list_or_type(env) { var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); var ret; var exit = 0; - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { switch (token$5) { case "T_IDENTIFIER" : ret = function_param_or_generic_type(env); @@ -6762,7 +6762,7 @@ function param_list_or_type(env) { if (match !== undefined) { var match$1 = Curry._2(Parser_env_Peek.token, 1, env); var exit$1 = 0; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { switch (match$1) { case "T_PLING" : case "T_COLON" : @@ -6831,7 +6831,7 @@ function function_param_list(env) { function prefix(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return postfix(env); } if (match !== "T_PLING") { @@ -6947,7 +6947,7 @@ function postfix_with(env, _t) { } function primitive(param) { - if (typeof param !== "string") { + if (typeof param === "object") { return ; } switch (param) { @@ -6972,7 +6972,7 @@ function function_param_or_generic_type(env) { var id = Curry._2(Parse.identifier, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_PLING" : case "T_COLON" : @@ -7008,7 +7008,7 @@ function primary(env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { switch (token$5) { case "T_IDENTIFIER" : var match = generic(env); @@ -7261,7 +7261,7 @@ function params(env, allow_default, _require_default, _acc) { var require_default = _require_default; var match = Curry._2(Parser_env_Peek.token, undefined, env); var variance; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_PLUS" : token$3(env); @@ -7284,7 +7284,7 @@ function params(env, allow_default, _require_default, _acc) { var match$3; if (allow_default) { var exit = 0; - if (typeof match$2 === "string" && match$2 === "T_ASSIGN") { + if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { token$3(env); match$3 = [ union(env), @@ -7327,7 +7327,7 @@ function params(env, allow_default, _require_default, _acc) { tl: acc }; var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$4 === "string") { + if (typeof match$4 !== "object") { switch (match$4) { case "T_GREATER_THAN" : case "T_EOF" : @@ -7375,7 +7375,7 @@ function union_with(env, left) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_BIT_OR") { + if (typeof match !== "object" && match === "T_BIT_OR") { token$4(env, "T_BIT_OR"); _acc = { hd: intersection(env), @@ -7409,7 +7409,7 @@ function function_param_list_without_parens(env) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t === "string") { + if (typeof t !== "object") { switch (t) { case "T_RPAREN" : case "T_ELLIPSIS" : @@ -7455,7 +7455,7 @@ function intersection_with(env, left) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_BIT_AND") { + if (typeof match !== "object" && match === "T_BIT_AND") { token$4(env, "T_BIT_AND"); _acc = { hd: prefix(env), @@ -7481,7 +7481,7 @@ function types(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RBRACKET" : case "T_EOF" : @@ -7594,7 +7594,7 @@ function indexer_property(env, start_loc, $$static) { function semicolon$1(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return error_unexpected(env); } switch (match) { @@ -7618,7 +7618,7 @@ function properties(allow_static, env, _param) { var $$static = allow_static && maybe(env, "T_STATIC"); var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LBRACKET" : var indexer = indexer_property(env, start_loc, $$static); @@ -7651,7 +7651,7 @@ function properties(allow_static, env, _param) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; var exit$1 = 0; - if ($$static && typeof match$1 === "string" && match$1 === "T_COLON") { + if ($$static && typeof match$1 !== "object" && match$1 === "T_COLON") { strict_error_at(env, [ start_loc, "StrictReservedWord" @@ -7691,7 +7691,7 @@ function properties(allow_static, env, _param) { var $$static$1 = match$2[0]; var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var property$1; - if (typeof match$3 === "string") { + if (typeof match$3 !== "object") { switch (match$3) { case "T_LPAREN" : case "T_LESS_THAN" : @@ -7761,7 +7761,7 @@ function params$1(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_GREATER_THAN" : case "T_EOF" : @@ -7832,7 +7832,7 @@ function annotation(env) { function annotation_opt(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_COLON") { + if (typeof match !== "object" && match === "T_COLON") { return annotation(env); } @@ -8013,7 +8013,7 @@ function param_list(env, _param) { var params = param$2[0]; var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t === "string") { + if (typeof t !== "object") { switch (t) { case "T_RPAREN" : case "T_ELLIPSIS" : @@ -8128,7 +8128,7 @@ function _function(env) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; var exit = 0; - if (match && typeof match$1 === "string") { + if (match && typeof match$1 !== "object") { switch (match$1) { case "T_LPAREN" : match$2 = [ @@ -8315,7 +8315,7 @@ function variable(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_VAR" : match$1 = declarations("T_VAR", "Var", env); @@ -8355,7 +8355,7 @@ function is_tighter(a, b) { function is_lhs(param) { var tmp = param[1]; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return false; } switch (tmp.TAG) { @@ -8369,7 +8369,7 @@ function is_lhs(param) { function is_assignable_lhs(param) { var tmp = param[1]; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return false; } switch (tmp.TAG) { @@ -8386,7 +8386,7 @@ function is_assignable_lhs(param) { function assignment_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var op; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RSHIFT3_ASSIGN" : op = "RShift3Assign"; @@ -8466,7 +8466,7 @@ function conditional(env) { function peek_unary_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return ; } switch (match) { @@ -8504,7 +8504,7 @@ function unary(env) { var loc = btwn(begin_loc, argument[0]); if (op === "Delete") { var tmp = argument[1]; - if (typeof tmp !== "string" && tmp.TAG === "Identifier") { + if (typeof tmp === "object" && tmp.TAG === "Identifier") { strict_error_at(env, [ loc, "StrictDelete" @@ -8526,7 +8526,7 @@ function unary(env) { } var match = Curry._2(Parser_env_Peek.token, undefined, env); var op$1; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_INCR" : op$1 = "Increment"; @@ -8547,7 +8547,7 @@ function unary(env) { } var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var op$2; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { switch (match$1) { case "T_INCR" : op$2 = "Increment"; @@ -8571,7 +8571,7 @@ function unary(env) { ]); } var match$2 = argument$1[1]; - if (typeof match$2 !== "string" && match$2.TAG === "Identifier") { + if (typeof match$2 === "object" && match$2.TAG === "Identifier") { if (is_restricted(match$2._0[1].name)) { strict_error(env, "StrictLHSPostfix"); } @@ -8600,7 +8600,7 @@ function unary(env) { ]); } var match$3 = argument$2[1]; - if (typeof match$3 !== "string" && match$3.TAG === "Identifier") { + if (typeof match$3 === "object" && match$3.TAG === "Identifier") { if (is_restricted(match$3._0[1].name)) { strict_error(env, "StrictLHSPrefix"); } @@ -8623,7 +8623,7 @@ function left_hand_side(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var expr; var exit = 0; - if (typeof match === "string" && match === "T_NEW") { + if (typeof match !== "object" && match === "T_NEW") { expr = _new(env, (function (new_expr, _args) { return new_expr; })); @@ -8635,7 +8635,7 @@ function left_hand_side(env) { } var expr$1 = member(env, expr); var part = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof part === "string") { + if (typeof part !== "object") { if (part === "T_LPAREN") { return call(env, expr$1); } else { @@ -8652,7 +8652,7 @@ function call(env, _left) { while(true) { var left = _left; var part = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof part !== "string") { + if (typeof part === "object") { if (part.TAG === "T_TEMPLATE_PART") { return tagged_template(env, left, part._0); } else { @@ -8726,7 +8726,7 @@ function _new(env, _finish_fn) { while(true) { var finish_fn = _finish_fn; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_NEW") { + if (typeof match !== "object" && match === "T_NEW") { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_NEW"); var finish_fn$p = (function(finish_fn,start_loc){ @@ -8761,17 +8761,17 @@ function _new(env, _finish_fn) { var callee = member(with_no_call(true, env), expr); var part = Curry._2(Parser_env_Peek.token, undefined, env); var callee$1; - callee$1 = typeof part === "string" || part.TAG !== "T_TEMPLATE_PART" ? callee : tagged_template(env, callee, part._0); + callee$1 = typeof part !== "object" || part.TAG !== "T_TEMPLATE_PART" ? callee : tagged_template(env, callee, part._0); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var args; - args = typeof match$1 === "string" && match$1 === "T_LPAREN" ? Curry._1($$arguments, env) : undefined; + args = typeof match$1 !== "object" && match$1 === "T_LPAREN" ? Curry._1($$arguments, env) : undefined; return Curry._2(finish_fn, callee$1, args); }; } function member(env, left) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return left; } switch (match) { @@ -8831,7 +8831,7 @@ function _function$1(env) { } else { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var id; - id = typeof match$1 === "string" && match$1 === "T_LESS_THAN" ? undefined : Curry._2(Parse.identifier, "StrictFunctionName", env); + id = typeof match$1 !== "object" && match$1 === "T_LESS_THAN" ? undefined : Curry._2(Parse.identifier, "StrictFunctionName", env); match = [ id, Curry._1(type_parameter_declaration$1, env) @@ -8909,7 +8909,7 @@ function primary$1(env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var number_type = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof number_type === "string") { + if (typeof number_type !== "object") { switch (number_type) { case "T_LCURLY" : var match = Curry._1(Parse.object_initializer, env); @@ -8925,7 +8925,7 @@ function primary$1(env) { var expression = Curry._1(assignment, env); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var ret; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { switch (match$1) { case "T_COMMA" : ret = sequence(env, { @@ -9022,7 +9022,7 @@ function primary$1(env) { var loc$2 = Curry._2(Parser_env_Peek.loc, undefined, env); var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); var match$5; - if (typeof match$4 === "string") { + if (typeof match$4 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -9235,7 +9235,7 @@ function sequence(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_COMMA") { + if (typeof match !== "object" && match === "T_COMMA") { token$4(env, "T_COMMA"); var expr = Curry._1(assignment, env); _acc = { @@ -9264,7 +9264,7 @@ function identifier_or_reserved_keyword(env) { var lex_value = Curry._2(Parser_env_Peek.value, undefined, env); var lex_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var exit = 0; - if (typeof lex_token === "string") { + if (typeof lex_token !== "object") { switch (lex_token) { case "T_IDENTIFIER" : case "T_DECLARE" : @@ -9283,7 +9283,7 @@ function identifier_or_reserved_keyword(env) { case 1 : var err; var exit$1 = 0; - if (typeof lex_token === "string") { + if (typeof lex_token !== "object") { switch (lex_token) { case "T_FUNCTION" : case "T_IF" : @@ -9389,7 +9389,7 @@ function assignment_but_not_arrow_function(env) { ]); } var match = expr[1]; - if (typeof match !== "string" && match.TAG === "Identifier") { + if (typeof match === "object" && match.TAG === "Identifier") { if (is_restricted(match._0[1].name)) { strict_error_at(env, [ expr[0], @@ -9425,7 +9425,7 @@ function try_assignment_but_not_arrow_function(env) { var env$1 = with_error_callback(error_callback, env); var ret = assignment_but_not_arrow_function(env$1); var match = Curry._2(Parser_env_Peek.token, undefined, env$1); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_ARROW" : case "T_COLON" : @@ -9447,7 +9447,7 @@ function try_assignment_but_not_arrow_function(env) { }; } var match$1 = ret[1]; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { return ret; } if (match$1.TAG !== "Identifier") { @@ -9469,7 +9469,7 @@ function assignment(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1 = Curry._2(Parser_env_Peek.is_identifier, undefined, env); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_YIELD" : if (env.allow_yield) { @@ -9516,11 +9516,11 @@ function assignment(env) { return assignment_but_not_arrow_function(env); } var expr = Curry._2(Parser_env_Try.to_parse, env, try_assignment_but_not_arrow_function); - if (typeof expr !== "string") { + if (typeof expr === "object") { return expr._0; } var expr$1 = Curry._2(Parser_env_Try.to_parse, env, try_arrow_function); - if (typeof expr$1 === "string") { + if (typeof expr$1 !== "object") { return assignment_but_not_arrow_function(env); } else { return expr$1._0; @@ -9546,7 +9546,7 @@ function logical_and(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return [ lloc, left @@ -9572,7 +9572,7 @@ function logical_or(env, _left, _lloc) { var lloc = _lloc; var left = _left; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return [ lloc, left @@ -9603,7 +9603,7 @@ function logical(env) { function binary_op(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var ret; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_IN" : ret = env.no_in ? undefined : [ @@ -9880,7 +9880,7 @@ function binary(env) { var right_loc = btwn(start_loc, end_loc); if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LESS_THAN") { var tmp = right[1]; - if (typeof tmp !== "string" && tmp.TAG === "JSXElement") { + if (typeof tmp === "object" && tmp.TAG === "JSXElement") { error(env, "AdjacentJSXElements"); } @@ -9922,7 +9922,7 @@ function binary(env) { function argument(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return { TAG: "Expression", _0: Curry._1(assignment, env) @@ -9953,7 +9953,7 @@ function arguments$p(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RPAREN" : case "T_EOF" : @@ -9997,11 +9997,11 @@ function template_parts(env, _quasis, _expressions) { tl: expressions }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_RCURLY") { + if (typeof match !== "object" && match === "T_RCURLY") { push_lex_mode(env, "TEMPLATE"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -10128,7 +10128,7 @@ function elements(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_COMMA" : token$4(env, "T_COMMA"); @@ -10193,7 +10193,7 @@ function array_initializer(env) { } function error_callback$1(param, param$1) { - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { switch (param$1) { case "StrictParamName" : case "NewlineBeforeArrow" : @@ -10262,7 +10262,7 @@ function try_arrow_function(env) { var generator = false; var env = with_in_function(true, param); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_LCURLY") { + if (typeof match !== "object" && match === "T_LCURLY") { var match$1 = function_body(env, async, generator); return [ match$1[1], @@ -10311,7 +10311,7 @@ function decorator_list_helper(env, _decorators) { while(true) { var decorators = _decorators; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return decorators; } if (match !== "T_AT") { @@ -10336,7 +10336,7 @@ function decorator_list(env) { function key(env) { var number_type = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof number_type === "string") { + if (typeof number_type !== "object") { if (number_type === "T_LBRACKET") { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_LBRACKET"); @@ -10538,7 +10538,7 @@ function property$1(env) { case "get" : var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$1 = 0; - if (typeof match$2 === "string") { + if (typeof match$2 !== "object") { switch (match$2) { case "T_LPAREN" : case "T_COLON" : @@ -10558,7 +10558,7 @@ function property$1(env) { case "set" : var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$2 = 0; - if (typeof match$3 === "string") { + if (typeof match$3 !== "object") { switch (match$3) { case "T_LPAREN" : case "T_COLON" : @@ -10647,7 +10647,7 @@ function init(env, start_loc, key, async, generator) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_COMMA" : @@ -10790,7 +10790,7 @@ function check_property(env, prop_map, prop) { switch (match$1.TAG) { case "Literal" : var s = match$1._0[1].value; - if (typeof s === "string") { + if (typeof s !== "object") { key = "null"; } else { switch (s.TAG) { @@ -10902,7 +10902,7 @@ function properties$1(env, _param) { var param = _param; var acc = param[1]; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -10963,7 +10963,7 @@ function class_implements(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -11014,7 +11014,7 @@ function set$1(env, start_loc, decorators, $$static) { function init$1(env, start_loc, decorators, key, async, generator, $$static) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_SEMICOLON" : case "T_ASSIGN" : @@ -11089,7 +11089,7 @@ function init$1(env, start_loc, decorators, key, async, generator, $$static) { switch (key.TAG) { case "Literal" : var match$4 = key._0[1].value; - kind = typeof match$4 === "string" || !(match$4.TAG === "String" && match$4._0 === "constructor") ? "Method" : "Constructor"; + kind = typeof match$4 !== "object" || !(match$4.TAG === "String" && match$4._0 === "constructor") ? "Method" : "Constructor"; break; case "Identifier" : kind = key._0[1].name === "constructor" ? "Constructor" : "Method"; @@ -11129,7 +11129,7 @@ function class_element(env) { case "get" : var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match$1 !== "string") { + if (typeof match$1 === "object") { return get$1(env, start_loc, decorators, $$static); } switch (match$1) { @@ -11150,7 +11150,7 @@ function class_element(env) { case "set" : var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var exit$1 = 0; - if (typeof match$2 !== "string") { + if (typeof match$2 === "object") { return set$1(env, start_loc, decorators, $$static); } switch (match$2) { @@ -11185,7 +11185,7 @@ function elements$1(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_SEMICOLON" : token$4(env, "T_SEMICOLON"); @@ -11287,7 +11287,7 @@ function class_expression(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var match$1; var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LCURLY" : case "T_EXTENDS" : @@ -11388,7 +11388,7 @@ function export_specifiers_and_errs(env, _specifiers, _errs) { var errs = _errs; var specifiers = _specifiers; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -11472,7 +11472,7 @@ function declare_var(env, start_loc) { function export_source(env) { contextual(env, "from"); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string" && match.TAG === "T_STRING") { + if (typeof match === "object" && match.TAG === "T_STRING") { var match$1 = match._0; var octal = match$1[3]; var raw = match$1[2]; @@ -11552,7 +11552,7 @@ function declare(in_moduleOpt, env) { } var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, 1, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_IDENTIFIER" : if (Curry._2(Parser_env_Peek.value, 1, env) === "module") { @@ -11576,7 +11576,7 @@ function declare(in_moduleOpt, env) { } else { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var id; - if (typeof match$1 === "string" || match$1.TAG !== "T_STRING") { + if (typeof match$1 !== "object" || match$1.TAG !== "T_STRING") { id = { TAG: "Identifier", _0: Curry._2(Parse.identifier, undefined, env) @@ -11768,14 +11768,14 @@ function declare_export_declaration(allow_export_typeOpt, env) { token$4(env$1, "T_EXPORT"); var match = Curry._2(Parser_env_Peek.token, undefined, env$1); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_DEFAULT" : token$4(env$1, "T_DEFAULT"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$2; var exit$1 = 0; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { switch (match$1) { case "T_FUNCTION" : var fn = declare_function(env$1, start_loc); @@ -11923,7 +11923,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { switch (exit) { case 1 : var match$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); - if (typeof match$5 === "string") { + if (typeof match$5 !== "object") { switch (match$5) { case "T_INTERFACE" : error(env$1, "DeclareExportInterface"); @@ -11967,7 +11967,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { var token$5 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$7; var exit$2 = 0; - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { switch (token$5) { case "T_FUNCTION" : var fn$1 = declare_function(env$1, start_loc); @@ -12017,7 +12017,7 @@ function declare_export_declaration(allow_export_typeOpt, env) { }; } if (exit$2 === 3) { - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { switch (token$5) { case "T_CONST" : error(env$1, "DeclareExportConst"); @@ -12067,7 +12067,7 @@ function supers(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -12109,7 +12109,7 @@ function supers$1(env, _acc) { tl: acc }; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return List.rev(acc$1); } if (match !== "T_COMMA") { @@ -12149,7 +12149,7 @@ function module_items(env, _module_kind, _acc) { var acc = _acc; var module_kind = _module_kind; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12167,7 +12167,7 @@ function module_items(env, _module_kind, _acc) { var module_kind$1; if (module_kind !== undefined) { if (module_kind.TAG === "CommonJS") { - if (typeof stmt$1 === "string") { + if (typeof stmt$1 !== "object") { module_kind$1 = module_kind; } else { switch (stmt$1.TAG) { @@ -12194,13 +12194,13 @@ function module_items(env, _module_kind, _acc) { module_kind$1 = module_kind; } } - } else if (typeof stmt$1 === "string" || stmt$1.TAG !== "DeclareModuleExports") { + } else if (typeof stmt$1 !== "object" || stmt$1.TAG !== "DeclareModuleExports") { module_kind$1 = module_kind; } else { error(env, "AmbiguousDeclareModuleKind"); module_kind$1 = module_kind; } - } else if (typeof stmt$1 === "string") { + } else if (typeof stmt$1 !== "object") { module_kind$1 = module_kind; } else { switch (stmt$1.TAG) { @@ -12350,7 +12350,7 @@ function case_list(env, _param) { var acc = param[1]; var seen_default = param[0]; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12362,7 +12362,7 @@ function case_list(env, _param) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var test; - if (typeof match$1 === "string" && match$1 === "T_DEFAULT") { + if (typeof match$1 !== "object" && match$1 === "T_DEFAULT") { if (seen_default) { error(env, "MultipleDefaultsInSwitch"); } @@ -12376,7 +12376,7 @@ function case_list(env, _param) { var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_COLON"); var term_fn = function (param) { - if (typeof param !== "string") { + if (typeof param === "object") { return false; } switch (param) { @@ -12429,7 +12429,7 @@ function var_or_const(env) { function source(env) { contextual(env, "from"); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string" && match.TAG === "T_STRING") { + if (typeof match === "object" && match.TAG === "T_STRING") { var match$1 = match._0; var octal = match$1[3]; var raw = match$1[2]; @@ -12481,7 +12481,7 @@ function specifier_list(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12530,7 +12530,7 @@ function specifier_list(env, _acc) { function named_or_namespace_specifier(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_MULT") { + if (typeof match !== "object" && match === "T_MULT") { token$4(env, "T_MULT"); contextual(env, "as"); var id = Curry._2(Parse.identifier, undefined, env); @@ -12554,7 +12554,7 @@ function named_or_namespace_specifier(env) { function from_expr(env, param) { var expr = param[1]; var loc = param[0]; - if (typeof expr !== "string") { + if (typeof expr === "object") { switch (expr.TAG) { case "Array" : var param$1 = [ @@ -12746,7 +12746,7 @@ function _object$2(restricted_error) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var prop; var exit = 0; - if (typeof match$1 === "string" && match$1 === "T_COLON") { + if (typeof match$1 !== "object" && match$1 === "T_COLON") { token$4(env, "T_COLON"); prop = [ pattern$1(env, restricted_error), @@ -12787,7 +12787,7 @@ function _object$2(restricted_error) { var pattern$3 = prop[0]; var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$4; - if (typeof match$2 === "string" && match$2 === "T_ASSIGN") { + if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { token$4(env, "T_ASSIGN"); var $$default = Curry._1(Parse.assignment, env); var loc$1 = btwn(pattern$3[0], $$default[0]); @@ -12821,7 +12821,7 @@ function _object$2(restricted_error) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_RCURLY" : case "T_EOF" : @@ -12881,7 +12881,7 @@ function _array(restricted_error) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_COMMA" : token$4(env, "T_COMMA"); @@ -12919,7 +12919,7 @@ function _array(restricted_error) { var pattern$2 = pattern$1(env, restricted_error); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var pattern$3; - if (typeof match$1 === "string" && match$1 === "T_ASSIGN") { + if (typeof match$1 !== "object" && match$1 === "T_ASSIGN") { token$4(env, "T_ASSIGN"); var $$default = Curry._1(Parse.expression, env); var loc$1 = btwn(pattern$2[0], $$default[0]); @@ -12984,7 +12984,7 @@ function _array(restricted_error) { function pattern$1(env, restricted_error) { var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LCURLY" : return _object$2(restricted_error)(env); @@ -13065,7 +13065,7 @@ function member_expression(env, _member) { while(true) { var member = _member; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return member; } if (match !== "T_PERIOD") { @@ -13094,7 +13094,7 @@ function member_expression(env, _member) { function name(env) { var name$1 = identifier$1(env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return { TAG: "Identifier", _0: name$1 @@ -13178,7 +13178,7 @@ function attribute(env) { token$4(env, "T_ASSIGN"); var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { if (token$5 === "T_LCURLY") { var match$2 = expression_container(env); var expression_container$1 = match$2[1]; @@ -13258,7 +13258,7 @@ function attributes(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LCURLY" : var attribute$1 = { @@ -13326,7 +13326,7 @@ function closing_element_without_lt(env, start_loc) { function child(env) { var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof token$5 === "string") { + if (typeof token$5 !== "object") { if (token$5 === "T_LCURLY") { var expression_container$1 = expression_container(env); return [ @@ -13374,7 +13374,7 @@ function element_or_closing(env) { var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_LESS_THAN"); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return { TAG: "ChildElement", _0: Curry._2(element_without_lt, env, start_loc) @@ -13399,7 +13399,7 @@ function children_and_closing(env, _acc) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LESS_THAN" : var closingElement = element_or_closing(env); @@ -13501,7 +13501,7 @@ function statement(env) { while(true) { var match = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_LCURLY" : var match$1 = Curry._1(Parse.block_body, env); @@ -13594,7 +13594,7 @@ function statement(env) { var block = Curry._1(Parse.block_body, env); var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); var handler; - if (typeof match$2 === "string" && match$2 === "T_CATCH") { + if (typeof match$2 !== "object" && match$2 === "T_CATCH") { var start_loc$4 = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_CATCH"); token$4(env, "T_LPAREN"); @@ -13624,7 +13624,7 @@ function statement(env) { } var match$3 = Curry._2(Parser_env_Peek.token, undefined, env); var finalizer; - if (typeof match$3 === "string" && match$3 === "T_FINALLY") { + if (typeof match$3 !== "object" && match$3 === "T_FINALLY") { token$4(env, "T_FINALLY"); finalizer = Curry._1(Parse.block_body, env); } else { @@ -13796,7 +13796,7 @@ function statement(env) { var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); var match$5; var exit$1 = 0; - if (typeof match$4 === "string") { + if (typeof match$4 !== "object") { switch (match$4) { case "T_SEMICOLON" : match$5 = [ @@ -13852,7 +13852,7 @@ function statement(env) { } var init = match$5[0]; var match$9 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$9 === "string") { + if (typeof match$9 !== "object") { switch (match$9) { case "T_IN" : assert_can_be_forin_or_forof(env, "InvalidLHSInForIn", init); @@ -13939,11 +13939,11 @@ function statement(env) { token$4(env, "T_SEMICOLON"); var match$10 = Curry._2(Parser_env_Peek.token, undefined, env); var test$2; - test$2 = typeof match$10 === "string" && match$10 === "T_SEMICOLON" ? undefined : Curry._1(Parse.expression, env); + test$2 = typeof match$10 !== "object" && match$10 === "T_SEMICOLON" ? undefined : Curry._1(Parse.expression, env); token$4(env, "T_SEMICOLON"); var match$11 = Curry._2(Parser_env_Peek.token, undefined, env); var update; - update = typeof match$11 === "string" && match$11 === "T_RPAREN" ? undefined : Curry._1(Parse.expression, env); + update = typeof match$11 !== "object" && match$11 === "T_RPAREN" ? undefined : Curry._1(Parse.expression, env); token$4(env, "T_RPAREN"); var body$6 = Curry._1(Parse.statement, with_in_loop(true, env)); return [ @@ -13986,7 +13986,7 @@ function statement(env) { var match$12 = Curry._2(Parser_env_Peek.token, undefined, env); var label$4 = expr$1[1]; var loc$11 = expr$1[0]; - if (typeof label$4 !== "string" && label$4.TAG === "Identifier" && typeof match$12 === "string" && match$12 === "T_COLON") { + if (typeof label$4 === "object" && label$4.TAG === "Identifier" && typeof match$12 !== "object" && match$12 === "T_COLON") { var label$5 = label$4._0; var match$13 = label$5[1]; var name$2 = match$13.name; @@ -14027,7 +14027,7 @@ function statement(env) { } ]; } - if (typeof match !== "string") { + if (typeof match === "object") { return expression(env); } switch (match) { @@ -14065,7 +14065,7 @@ function statement(env) { function module_item(env) { var decorators = decorator_list(env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "string") { + if (typeof match === "object") { return statement_list_item(decorators, env); } switch (match) { @@ -14075,7 +14075,7 @@ function module_item(env) { token$4(env$1, "T_EXPORT"); var match$1 = Curry._2(Parser_env_Peek.token, undefined, env$1); var exit = 0; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { switch (match$1) { case "T_DEFAULT" : token$4(env$1, "T_DEFAULT"); @@ -14086,7 +14086,7 @@ function module_item(env) { var match$2 = Curry._2(Parser_env_Peek.token, undefined, env$1); var match$3; var exit$1 = 0; - if (typeof match$2 === "string" && match$2 === "T_FUNCTION") { + if (typeof match$2 !== "object" && match$2 === "T_FUNCTION") { var fn = _function(env$1); match$3 = [ fn[0], @@ -14141,7 +14141,7 @@ function module_item(env) { } var $$interface$1 = $$interface(env$1); var match$4 = $$interface$1[1]; - if (typeof match$4 === "string") { + if (typeof match$4 !== "object") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!", @@ -14184,7 +14184,7 @@ function module_item(env) { } var type_alias$1 = type_alias(env$1); var match$5 = type_alias$1[1]; - if (typeof match$5 === "string") { + if (typeof match$5 !== "object") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!", @@ -14270,7 +14270,7 @@ function module_item(env) { case 1 : var match$6 = Curry._2(Parser_env_Peek.token, undefined, env$1); var exportKind; - if (typeof match$6 === "string" && match$6 === "T_TYPE") { + if (typeof match$6 !== "object" && match$6 === "T_TYPE") { token$3(env$1); exportKind = "ExportType"; } else { @@ -14310,7 +14310,7 @@ function module_item(env) { var match$8 = stmt[1]; var loc$4 = stmt[0]; var names; - if (typeof match$8 === "string") { + if (typeof match$8 !== "object") { throw { RE_EXN_ID: "Failure", _1: "Internal Flow Error! Unexpected export statement declaration!", @@ -14400,7 +14400,7 @@ function module_item(env) { token$4(env$2, "T_IMPORT"); var match$9 = Curry._2(Parser_env_Peek.token, undefined, env$2); var match$10; - if (typeof match$9 === "string") { + if (typeof match$9 !== "object") { switch (match$9) { case "T_TYPEOF" : if (!env$2.parse_options.types) { @@ -14439,7 +14439,7 @@ function module_item(env) { var match$12 = Curry._2(Parser_env_Peek.is_identifier, undefined, env$2); var exit$2 = 0; var exit$3 = 0; - if (typeof match$11 === "string") { + if (typeof match$11 !== "object") { if (match$11 === "T_COMMA") { exit$2 = 1; } else { @@ -14522,7 +14522,7 @@ function module_item(env) { var match$15 = Curry._2(Parser_env_Peek.value, undefined, env$2); var match$16; var exit$4 = 0; - if (type_ident !== undefined && typeof match$14 === "string") { + if (type_ident !== undefined && typeof match$14 !== "object") { switch (match$14) { case "T_IDENTIFIER" : if (match$15 === "from") { @@ -14563,7 +14563,7 @@ function module_item(env) { } var match$17 = Curry._2(Parser_env_Peek.token, undefined, env$2); var additional_specifiers; - if (typeof match$17 === "string" && match$17 === "T_COMMA") { + if (typeof match$17 !== "object" && match$17 === "T_COMMA") { token$4(env$2, "T_COMMA"); additional_specifiers = named_or_namespace_specifier(env$2); } else { @@ -14606,7 +14606,7 @@ function statement_list_item(decoratorsOpt, env) { error_on_decorators(env)(decorators); } var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string") { + if (typeof match !== "object") { switch (match) { case "T_CONST" : return var_or_const(env); @@ -14670,7 +14670,7 @@ function statement_list_item(decoratorsOpt, env) { if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { return class_declaration$1(env, decorators); } - if (typeof match !== "string") { + if (typeof match === "object") { return statement(env); } switch (match) { @@ -14694,7 +14694,7 @@ function statement_list(_env, term_fn, item_fn, _param) { var stmts = param[1]; var string_tokens = param[0]; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "string" && t === "T_EOF") { + if (typeof t !== "object" && t === "T_EOF") { return [ env, string_tokens, @@ -14720,7 +14720,7 @@ function statement_list(_env, term_fn, item_fn, _param) { tl: stmts }; var match = possible_directive[1]; - if (typeof match === "string") { + if (typeof match !== "object") { return [ env, string_tokens, @@ -14736,7 +14736,7 @@ function statement_list(_env, term_fn, item_fn, _param) { } var match$1 = match._0.expression; var match$2 = match$1[1]; - if (typeof match$2 === "string") { + if (typeof match$2 !== "object") { return [ env, string_tokens, @@ -14751,7 +14751,7 @@ function statement_list(_env, term_fn, item_fn, _param) { ]; } var str = match$2._0.value; - if (typeof str === "string") { + if (typeof str !== "object") { return [ env, string_tokens, @@ -14789,7 +14789,7 @@ function directives(env, term_fn, item_fn) { var env$1 = match[0]; List.iter((function (param) { var token = param[1]; - if (typeof token !== "string" && token.TAG === "T_STRING") { + if (typeof token === "object" && token.TAG === "T_STRING") { if (token._0[3]) { return strict_error_at(env$1, [ param[0], @@ -14817,7 +14817,7 @@ function module_body(term_fn, env) { while(true) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "string" && t === "T_EOF") { + if (typeof t !== "object" && t === "T_EOF") { return List.rev(acc); } if (Curry._1(term_fn, t)) { @@ -14836,7 +14836,7 @@ function statement_list$1(term_fn, env) { while(true) { var acc = _acc; var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t === "string" && t === "T_EOF") { + if (typeof t !== "object" && t === "T_EOF") { return List.rev(acc); } if (Curry._1(term_fn, t)) { @@ -14884,7 +14884,7 @@ function identifier$2(restricted_error, env) { var name = Curry._2(Parser_env_Peek.value, undefined, env); var t = Curry._2(Parser_env_Peek.token, undefined, env); var exit = 0; - if (typeof t === "string" && t === "T_LET") { + if (typeof t !== "object" && t === "T_LET") { if (env.in_strict_mode) { strict_error(env, "StrictReservedWord"); } else if (env.no_let) { @@ -14901,7 +14901,7 @@ function identifier$2(restricted_error, env) { if (is_strict_reserved(name)) { strict_error(env, "StrictReservedWord"); token$3(env); - } else if (typeof t === "string") { + } else if (typeof t !== "object") { switch (t) { case "T_DECLARE" : case "T_TYPE" : @@ -14951,7 +14951,7 @@ function program(env) { function expression$1(env) { var expr = Curry._1(assignment, env); var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "string" && match === "T_COMMA") { + if (typeof match !== "object" && match === "T_COMMA") { return sequence(env, { hd: expr, tl: /* [] */0 @@ -15275,7 +15275,7 @@ function parse(content, options) { var loc = function ($$location) { var match = $$location.source; var source = match !== undefined ? ( - typeof match === "string" ? string("(global)") : string(match._0) + typeof match !== "object" ? string("(global)") : string(match._0) ) : $$null; return obj([ [ @@ -15332,7 +15332,7 @@ function parse(content, options) { var _type = function (param) { var t = param[1]; var loc = param[0]; - if (typeof t === "string") { + if (typeof t !== "object") { switch (t) { case "Any" : return node("AnyTypeAnnotation", loc, []); @@ -15562,7 +15562,7 @@ function parse(content, options) { var expression = function (param) { var arr = param[1]; var loc = param[0]; - if (typeof arr === "string") { + if (typeof arr !== "object") { return node("ThisExpression", loc, []); } switch (arr.TAG) { @@ -16202,7 +16202,7 @@ function parse(content, options) { var statement = function (param) { var b = param[1]; var loc = param[0]; - if (typeof b === "string") { + if (typeof b !== "object") { if (b === "Empty") { return node("EmptyStatement", loc, []); } else { @@ -16846,7 +16846,7 @@ function parse(content, options) { var value = lit.value; var loc = param[0]; var value_; - if (typeof value === "string") { + if (typeof value !== "object") { value_ = $$null; } else { switch (value.TAG) { @@ -16868,7 +16868,7 @@ function parse(content, options) { } var props; var exit = 0; - if (typeof value === "string" || value.TAG !== "RegExp") { + if (typeof value !== "object" || value.TAG !== "RegExp") { exit = 1; } else { var match$1 = value._0; diff --git a/jscomp/test/fun_pattern_match.js b/jscomp/test/fun_pattern_match.js index c4cf868f52..aa1b6bdae0 100644 --- a/jscomp/test/fun_pattern_match.js +++ b/jscomp/test/fun_pattern_match.js @@ -15,10 +15,10 @@ function f3(param) { var lhs = param.rank; return function (param) { var rhs = param.rank; - if (typeof lhs === "string") { + if (typeof lhs !== "object") { lhs === "Uninitialized"; } else { - if (typeof rhs !== "string") { + if (typeof rhs === "object") { return Caml.int_compare(lhs._0, rhs._0); } rhs === "Uninitialized"; @@ -39,10 +39,10 @@ function f4(param) { var lhs = param.rank; return function (param) { var rhs = param.rank; - if (typeof lhs === "string") { + if (typeof lhs !== "object") { lhs === "Uninitialized"; } else { - if (typeof rhs !== "string") { + if (typeof rhs === "object") { return Caml.int_compare(lhs._0, rhs._0); } rhs === "Uninitialized"; diff --git a/jscomp/test/gpr_1658_test.js b/jscomp/test/gpr_1658_test.js index d7ebf14294..a1d16e8f13 100644 --- a/jscomp/test/gpr_1658_test.js +++ b/jscomp/test/gpr_1658_test.js @@ -32,7 +32,7 @@ eq("File \"gpr_1658_test.ml\", line 11, characters 7-14", null, null); var match = Js_types.classify(null); -if (typeof match === "string" && match === "JSNull") { +if (typeof match !== "object" && match === "JSNull") { eq("File \"gpr_1658_test.ml\", line 14, characters 11-18", true, true); } else { eq("File \"gpr_1658_test.ml\", line 16, characters 11-18", true, false); diff --git a/jscomp/test/gpr_3209_test.js b/jscomp/test/gpr_3209_test.js index e1274256fa..1d0f435ec9 100644 --- a/jscomp/test/gpr_3209_test.js +++ b/jscomp/test/gpr_3209_test.js @@ -2,7 +2,7 @@ function f9(param) { - if (typeof param === "string") { + if (typeof param !== "object") { switch (param) { case "T60" : case "T61" : diff --git a/jscomp/test/gpr_3609_test.js b/jscomp/test/gpr_3609_test.js index a610dcff33..eb5ac991ac 100644 --- a/jscomp/test/gpr_3609_test.js +++ b/jscomp/test/gpr_3609_test.js @@ -2,7 +2,7 @@ function func(state) { - if (typeof state === "string") { + if (typeof state !== "object") { return 0; } else { return 0 + state._0 | 0; diff --git a/jscomp/test/gpr_4900_test.js b/jscomp/test/gpr_4900_test.js index 02d5735791..3c6e35f7bd 100644 --- a/jscomp/test/gpr_4900_test.js +++ b/jscomp/test/gpr_4900_test.js @@ -11,7 +11,7 @@ var test_id = { }; function showToJs(x) { - if (typeof x === "string" && x === "No") { + if (typeof x !== "object" && x === "No") { return false; } else { return true; diff --git a/jscomp/test/gpr_4924_test.js b/jscomp/test/gpr_4924_test.js index 92bbb605c6..417fa0305f 100644 --- a/jscomp/test/gpr_4924_test.js +++ b/jscomp/test/gpr_4924_test.js @@ -11,7 +11,7 @@ var test_id = { }; function u(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return 0; } else { return 1; @@ -19,7 +19,7 @@ function u(b) { } function u1(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return true; } else { return false; @@ -27,7 +27,7 @@ function u1(b) { } function u2(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return false; } else { return true; @@ -41,7 +41,7 @@ Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.ml\", line 26, characters 30 Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.ml\", line 27, characters 30-37", true, true); function u3(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return 3; } else { return 4; @@ -49,7 +49,7 @@ function u3(b) { } function u4(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return 3; } else { return 4; @@ -57,7 +57,7 @@ function u4(b) { } function u5(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return false; } else { return true; @@ -65,7 +65,7 @@ function u5(b) { } function u6(b) { - if (typeof b === "string" && b === "A") { + if (typeof b !== "object" && b === "A") { return true; } else { return false; diff --git a/jscomp/test/gpr_5280_optimize_test.js b/jscomp/test/gpr_5280_optimize_test.js index 7d78503132..fcb9872410 100644 --- a/jscomp/test/gpr_5280_optimize_test.js +++ b/jscomp/test/gpr_5280_optimize_test.js @@ -7,7 +7,7 @@ var a = /* Color */{ var c; -c = typeof a === "string" ? "orange" : "white"; +c = typeof a !== "object" ? "orange" : "white"; exports.a = a; exports.c = c; diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index 35b3ea2754..8796f62080 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -8,7 +8,7 @@ var Caml_option = require("../../lib/js/caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._4; @@ -36,11 +36,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -54,7 +54,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -72,7 +72,7 @@ function Make(Ord) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +86,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -96,14 +96,14 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -134,7 +134,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -151,7 +151,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param._1); @@ -165,14 +165,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param._1, param._2 @@ -185,14 +185,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param._1, param._2 @@ -203,7 +203,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -211,14 +211,14 @@ function Make(Ord) { }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._3; } else { return bal(remove_min_binding(l), param._1, param._2, param._3); } }; var remove = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var r = param._3; @@ -227,10 +227,10 @@ function Make(Ord) { var l = param._0; var c = Curry._2(Ord.compare, x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; } - if (typeof r === "string") { + if (typeof r !== "object") { return l; } var match = min_binding(r); @@ -244,7 +244,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param._0); @@ -254,7 +254,7 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param._0); @@ -269,7 +269,7 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param._1; @@ -288,7 +288,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); @@ -299,7 +299,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -315,7 +315,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -329,25 +329,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, v); } else { return bal(add_min_binding(k, v, param._0), param._1, param._2, param._3); } }; var add_max_binding = function (k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, v); } else { return bal(param._0, param._1, param._2, add_max_binding(k, v, param._3)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l._4; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r._4; @@ -360,10 +360,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -377,7 +377,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -412,8 +412,8 @@ function Make(Ord) { ]; }; var merge = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -425,7 +425,7 @@ function Make(Ord) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -441,7 +441,7 @@ function Make(Ord) { return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); }; var filter = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var d = param._2; @@ -456,7 +456,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -487,7 +487,7 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -506,14 +506,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -535,14 +535,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -557,7 +557,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._3) | 0; @@ -567,7 +567,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param._0; @@ -624,7 +624,7 @@ function Make(Ord) { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._4; @@ -655,11 +655,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -673,7 +673,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -691,7 +691,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -705,7 +705,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -716,7 +716,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -724,7 +724,7 @@ function is_empty(param) { } function add(x, data, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -756,7 +756,7 @@ function add(x, data, param) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -774,7 +774,7 @@ function find(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.int_compare(x, param._1); @@ -789,14 +789,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param._1, param._2 @@ -810,14 +810,14 @@ function min_binding(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param._1, param._2 @@ -829,7 +829,7 @@ function max_binding(_param) { } function remove_min_binding(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -837,7 +837,7 @@ function remove_min_binding(param) { }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._3; } else { return bal(remove_min_binding(l), param._1, param._2, param._3); @@ -845,7 +845,7 @@ function remove_min_binding(param) { } function remove(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var r = param._3; @@ -854,10 +854,10 @@ function remove(x, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; } - if (typeof r === "string") { + if (typeof r !== "object") { return l; } var match = min_binding(r); @@ -872,7 +872,7 @@ function remove(x, param) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param._0); @@ -883,7 +883,7 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param._0); @@ -899,7 +899,7 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param._1; @@ -919,7 +919,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); @@ -931,7 +931,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -948,7 +948,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -963,7 +963,7 @@ function exists(p, _param) { } function add_min_binding(k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, v); } else { return bal(add_min_binding(k, v, param._0), param._1, param._2, param._3); @@ -971,7 +971,7 @@ function add_min_binding(k, v, param) { } function add_max_binding(k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, v); } else { return bal(param._0, param._1, param._2, add_max_binding(k, v, param._3)); @@ -979,11 +979,11 @@ function add_max_binding(k, v, param) { } function join(l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l._4; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r._4; @@ -997,10 +997,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -1016,7 +1016,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -1052,8 +1052,8 @@ function split(x, param) { } function merge(f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -1065,7 +1065,7 @@ function merge(f, s1, s2) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1082,7 +1082,7 @@ function merge(f, s1, s2) { } function filter(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var d = param._2; @@ -1098,7 +1098,7 @@ function filter(p, param) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -1130,7 +1130,7 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -1150,14 +1150,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -1180,14 +1180,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (e1._0 !== e2._0) { @@ -1203,7 +1203,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._3) | 0; @@ -1214,7 +1214,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param._0; @@ -1300,7 +1300,7 @@ var m = List.fold_left((function (acc, param) { }); function height$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._4; @@ -1331,11 +1331,11 @@ function singleton$1(x, d) { function bal$1(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -1349,7 +1349,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); } throw { @@ -1367,7 +1367,7 @@ function bal$1(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -1381,7 +1381,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); } throw { @@ -1392,7 +1392,7 @@ function bal$1(l, x, d, r) { } function is_empty$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -1400,7 +1400,7 @@ function is_empty$1(param) { } function add$1(x, data, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -1432,7 +1432,7 @@ function add$1(x, data, param) { function find$1(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1450,7 +1450,7 @@ function find$1(x, _param) { function mem$1(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.string_compare(x, param._1); @@ -1465,14 +1465,14 @@ function mem$1(x, _param) { function min_binding$1(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param._1, param._2 @@ -1486,14 +1486,14 @@ function min_binding$1(_param) { function max_binding$1(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._3; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param._1, param._2 @@ -1505,7 +1505,7 @@ function max_binding$1(_param) { } function remove_min_binding$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -1513,7 +1513,7 @@ function remove_min_binding$1(param) { }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._3; } else { return bal$1(remove_min_binding$1(l), param._1, param._2, param._3); @@ -1521,7 +1521,7 @@ function remove_min_binding$1(param) { } function remove$1(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var r = param._3; @@ -1530,10 +1530,10 @@ function remove$1(x, param) { var l = param._0; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; } - if (typeof r === "string") { + if (typeof r !== "object") { return l; } var match = min_binding$1(r); @@ -1548,7 +1548,7 @@ function remove$1(x, param) { function iter$1(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter$1(f, param._0); @@ -1559,7 +1559,7 @@ function iter$1(f, _param) { } function map$1(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map$1(f, param._0); @@ -1575,7 +1575,7 @@ function map$1(f, param) { } function mapi$1(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param._1; @@ -1595,7 +1595,7 @@ function fold$1(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m._1, m._2, fold$1(f, m._0, accu)); @@ -1607,7 +1607,7 @@ function fold$1(f, _m, _accu) { function for_all$1(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param._1, param._2)) { @@ -1624,7 +1624,7 @@ function for_all$1(p, _param) { function exists$1(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param._1, param._2)) { @@ -1639,7 +1639,7 @@ function exists$1(p, _param) { } function add_min_binding$1(k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton$1(k, v); } else { return bal$1(add_min_binding$1(k, v, param._0), param._1, param._2, param._3); @@ -1647,7 +1647,7 @@ function add_min_binding$1(k, v, param) { } function add_max_binding$1(k, v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton$1(k, v); } else { return bal$1(param._0, param._1, param._2, add_max_binding$1(k, v, param._3)); @@ -1655,11 +1655,11 @@ function add_max_binding$1(k, v, param) { } function join$1(l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding$1(v, d, r); } var lh = l._4; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding$1(v, d, l); } var rh = r._4; @@ -1673,10 +1673,10 @@ function join$1(l, v, d, r) { } function concat$1(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding$1(t2); @@ -1692,7 +1692,7 @@ function concat_or_join$1(t1, v, d, t2) { } function split$1(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -1728,8 +1728,8 @@ function split$1(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -1741,7 +1741,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1758,7 +1758,7 @@ function merge$1(f, s1, s2) { } function filter$1(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var d = param._2; @@ -1774,7 +1774,7 @@ function filter$1(p, param) { } function partition$1(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -1806,7 +1806,7 @@ function cons_enum$1(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -1826,14 +1826,14 @@ function compare$1(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -1856,14 +1856,14 @@ function equal$1(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Caml.string_compare(e1._0, e2._0) !== 0) { @@ -1879,7 +1879,7 @@ function equal$1(cmp, m1, m2) { } function cardinal$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal$1(param._0) + 1 | 0) + cardinal$1(param._3) | 0; @@ -1890,7 +1890,7 @@ function bindings_aux$1(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param._0; diff --git a/jscomp/test/inline_map_demo.js b/jscomp/test/inline_map_demo.js index b7e98c4921..a00cec9079 100644 --- a/jscomp/test/inline_map_demo.js +++ b/jscomp/test/inline_map_demo.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return 0; } else { return x._4; @@ -26,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -48,7 +48,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -70,7 +70,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -88,7 +88,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -103,7 +103,7 @@ function bal(l, x, d, r) { } function add(x, data, tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -163,7 +163,7 @@ var m = List.fold_left((function (acc, param) { function find(px, _x) { while(true) { var x = _x; - if (typeof x === "string") { + if (typeof x !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/inline_map_test.js b/jscomp/test/inline_map_test.js index e59360bb30..2e50ecc5fb 100644 --- a/jscomp/test/inline_map_test.js +++ b/jscomp/test/inline_map_test.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._4; @@ -26,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l._4; + hl = typeof l !== "object" ? 0 : l._4; var hr; - hr = typeof r === "string" ? 0 : r._4; + hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -44,7 +44,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } throw { @@ -62,7 +62,7 @@ function bal(l, x, d, r) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -76,7 +76,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } throw { @@ -87,7 +87,7 @@ function bal(l, x, d, r) { } function add(x, data, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -119,7 +119,7 @@ function add(x, data, param) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 15c8bbf6f8..50de18de3f 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -181,7 +181,7 @@ if (v6.RE_EXN_ID === A4) { eq("File \"inline_record_test.ml\", line 87, characters 6-13", tmp$3, 11); function ff1(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return "A1"; } else { return /* A0 */{ diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index 708223fc33..6cda098613 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -36,11 +36,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -54,7 +54,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -72,7 +72,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +86,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -97,7 +97,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -105,7 +105,7 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -151,7 +151,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -169,7 +169,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -184,7 +184,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -209,7 +209,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -221,7 +221,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -246,7 +246,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -261,7 +261,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -286,7 +286,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -298,7 +298,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -323,7 +323,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Caml.int_compare(x, param.v); @@ -338,7 +338,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.int_compare(x, param.v); @@ -353,14 +353,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -374,11 +374,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -392,14 +392,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -413,11 +413,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -429,7 +429,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -437,7 +437,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -445,10 +445,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -456,7 +456,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -484,7 +484,7 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -540,7 +540,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -551,7 +551,7 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -567,7 +567,7 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -587,7 +587,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -599,7 +599,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -616,7 +616,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -631,7 +631,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -639,7 +639,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -647,11 +647,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -665,10 +665,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -684,7 +684,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -720,8 +720,8 @@ function split(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -733,7 +733,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -750,12 +750,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -783,7 +783,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -805,7 +805,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -837,7 +837,7 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -857,14 +857,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -887,14 +887,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (e1._0 !== e2._0) { @@ -910,7 +910,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -921,7 +921,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index 733dee33ec..65db2c777f 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -61,7 +61,7 @@ var v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param) { var ty = Js_json.classify(v); - if (typeof ty === "string") { + if (typeof ty !== "object") { return { TAG: "Ok", _0: false @@ -81,7 +81,7 @@ add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param }; } var ty2 = Js_json.classify(Caml_option.valFromOption(v$1)); - if (typeof ty2 === "string") { + if (typeof ty2 !== "object") { return { TAG: "Ok", _0: false @@ -95,7 +95,7 @@ add_test("File \"js_json_test.ml\", line 24, characters 11-18", (function (param } ty2._0.forEach(function (x) { var ty3 = Js_json.classify(x); - if (typeof ty3 === "string") { + if (typeof ty3 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -131,7 +131,7 @@ var json = JSON.parse(JSON.stringify(null)); var ty = Js_json.classify(json); -if (typeof ty === "string") { +if (typeof ty !== "object") { if (ty === "JSONNull") { add_test("File \"js_json_test.ml\", line 55, characters 24-31", (function (param) { return { @@ -162,7 +162,7 @@ var json$1 = JSON.parse(JSON.stringify("test string")); var ty$1 = Js_json.classify(json$1); -if (typeof ty$1 === "string") { +if (typeof ty$1 !== "object") { add_test("File \"js_json_test.ml\", line 66, characters 16-23", (function (param) { return { TAG: "Ok", @@ -186,7 +186,7 @@ var ty$2 = Js_json.classify(json$2); var exit = 0; -if (typeof ty$2 === "string" || ty$2.TAG !== "JSONNumber") { +if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { exit = 1; } else { eq("File \"js_json_test.ml\", line 75, characters 25-32", ty$2._0, 1.23456789); @@ -207,7 +207,7 @@ var ty$3 = Js_json.classify(json$3); var exit$1 = 0; -if (typeof ty$3 === "string" || ty$3.TAG !== "JSONNumber") { +if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { exit$1 = 1; } else { eq("File \"js_json_test.ml\", line 85, characters 25-32", ty$3._0 | 0, -1347440721); @@ -225,7 +225,7 @@ if (exit$1 === 1) { function test(v) { var json = JSON.parse(JSON.stringify(v)); var ty = Js_json.classify(json); - if (typeof ty !== "string") { + if (typeof ty === "object") { return add_test("File \"js_json_test.ml\", line 97, characters 18-25", (function (param) { return { TAG: "Ok", @@ -277,7 +277,7 @@ var json$4 = JSON.parse(JSON.stringify(dict)); var ty$4 = Js_json.classify(json$4); -if (typeof ty$4 === "string") { +if (typeof ty$4 !== "object") { add_test("File \"js_json_test.ml\", line 135, characters 16-23", (function (param) { return { TAG: "Ok", @@ -287,7 +287,7 @@ if (typeof ty$4 === "string") { } else if (ty$4.TAG === "JSONObject") { var x = ty$4._0; var ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); - if (typeof ta === "string") { + if (typeof ta !== "object") { add_test("File \"js_json_test.ml\", line 133, characters 18-25", (function (param) { return { TAG: "Ok", @@ -304,7 +304,7 @@ if (typeof ty$4 === "string") { })); } else { var ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); - if (typeof ty$5 === "string") { + if (typeof ty$5 !== "object") { add_test("File \"js_json_test.ml\", line 131, characters 22-29", (function (param) { return { TAG: "Ok", @@ -348,7 +348,7 @@ if (typeof ty$4 === "string") { function eq_at_i(loc, json, i, kind, expected) { var ty = Js_json.classify(json); - if (typeof ty === "string") { + if (typeof ty !== "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -367,7 +367,7 @@ function eq_at_i(loc, json, i, kind, expected) { var ty$1 = Js_json.classify(Caml_array.get(ty._0, i)); switch (kind) { case "String" : - if (typeof ty$1 === "string") { + if (typeof ty$1 !== "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -385,7 +385,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Number" : - if (typeof ty$1 === "string") { + if (typeof ty$1 !== "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -403,7 +403,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Object" : - if (typeof ty$1 === "string") { + if (typeof ty$1 !== "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -421,7 +421,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Array" : - if (typeof ty$1 === "string") { + if (typeof ty$1 !== "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -439,7 +439,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Boolean" : - if (typeof ty$1 !== "string") { + if (typeof ty$1 === "object") { return add_test(loc, (function (param) { return { TAG: "Ok", @@ -461,7 +461,7 @@ function eq_at_i(loc, json, i, kind, expected) { })); } case "Null" : - if (typeof ty$1 === "string") { + if (typeof ty$1 !== "object") { if (ty$1 === "JSONNull") { return add_test(loc, (function (param) { return { @@ -575,7 +575,7 @@ var json$10 = JSON.parse(JSON.stringify(a$3)); var ty$6 = Js_json.classify(json$10); -if (typeof ty$6 === "string") { +if (typeof ty$6 !== "object") { add_test("File \"js_json_test.ml\", line 283, characters 16-23", (function (param) { return { TAG: "Ok", @@ -584,7 +584,7 @@ if (typeof ty$6 === "string") { })); } else if (ty$6.TAG === "JSONArray") { var ty$7 = Js_json.classify(Caml_array.get(ty$6._0, 1)); - if (typeof ty$7 === "string") { + if (typeof ty$7 !== "object") { add_test("File \"js_json_test.ml\", line 281, characters 18-25", (function (param) { return { TAG: "Ok", @@ -593,7 +593,7 @@ if (typeof ty$6 === "string") { })); } else if (ty$7.TAG === "JSONObject") { var ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); - if (typeof ty$8 === "string") { + if (typeof ty$8 !== "object") { add_test("File \"js_json_test.ml\", line 279, characters 20-27", (function (param) { return { TAG: "Ok", diff --git a/jscomp/test/large_record_duplication_test.js b/jscomp/test/large_record_duplication_test.js index 8433fe2b9d..d6766ec4c8 100644 --- a/jscomp/test/large_record_duplication_test.js +++ b/jscomp/test/large_record_duplication_test.js @@ -83,7 +83,7 @@ var v1 = /* A0 */{ }; function get_x0(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return ; } else { return x.x0; @@ -91,7 +91,7 @@ function get_x0(x) { } function f1(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return "A1"; } var newrecord = Caml_obj.obj_dup(x); diff --git a/jscomp/test/map_find_test.js b/jscomp/test/map_find_test.js index 62780dd08d..b26f9efda4 100644 --- a/jscomp/test/map_find_test.js +++ b/jscomp/test/map_find_test.js @@ -5,7 +5,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -26,11 +26,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -44,7 +44,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -62,7 +62,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -76,7 +76,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -87,7 +87,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -133,7 +133,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -177,7 +177,7 @@ var m = List.fold_left((function (acc, param) { }); function height$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -198,11 +198,11 @@ function create$1(l, x, d, r) { function bal$1(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -216,7 +216,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } throw { @@ -234,7 +234,7 @@ function bal$1(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -248,7 +248,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } throw { @@ -259,7 +259,7 @@ function bal$1(l, x, d, r) { } function add$1(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -305,7 +305,7 @@ function add$1(x, data, m) { function find$1(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index 6b6c80111d..90b9610244 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -6,7 +6,7 @@ var List = require("../../lib/js/list.js"); var Curry = require("../../lib/js/curry.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -27,11 +27,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -45,7 +45,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -63,7 +63,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -77,7 +77,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -88,7 +88,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -135,7 +135,7 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -155,14 +155,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -185,14 +185,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (e1._0 !== e2._0) { @@ -208,7 +208,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -216,7 +216,7 @@ function cardinal(param) { } function height$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -237,11 +237,11 @@ function create$1(l, x, d, r) { function bal$1(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -255,7 +255,7 @@ function bal$1(l, x, d, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } throw { @@ -273,7 +273,7 @@ function bal$1(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -287,7 +287,7 @@ function bal$1(l, x, d, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } throw { @@ -298,7 +298,7 @@ function bal$1(l, x, d, r) { } function add$1(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -344,7 +344,7 @@ function add$1(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index fee4aacba4..8c431cc0d3 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -554,7 +554,7 @@ function make_type(typ, dir) { } case "SBlock" : var x$1 = typ._0; - if (typeof x$1 !== "string") { + if (typeof x$1 === "object") { return setup_sprite(undefined, undefined, undefined, "blocks.png", 4, 15, [ 16, 16 @@ -1358,7 +1358,7 @@ function kill(collid, ctx) { case "Block" : var o$2 = collid._2; var tmp = collid._0; - if (typeof tmp !== "string") { + if (typeof tmp === "object") { return /* [] */0; } if (tmp !== "Brick") { @@ -1695,7 +1695,7 @@ function process_collision(dir, c1, c2, state) { var o2$4 = c2._2; var t = c2._0; if (dir === "North") { - if (typeof t === "string") { + if (typeof t !== "object") { switch (t) { case "Brick" : if (c1._0 === "BigM") { @@ -1736,7 +1736,7 @@ function process_collision(dir, c1, c2, state) { } } else { var exit$1 = 0; - if (typeof t === "string") { + if (typeof t !== "object") { if (t === "Panel") { game_win(state.ctx); return [ @@ -1917,7 +1917,7 @@ function process_collision(dir, c1, c2, state) { var typ$2; switch (t1) { case "GKoopaShell" : - if (typeof t2$3 === "string") { + if (typeof t2$3 !== "object") { if (t2$3 === "Brick") { dec_health(o2$6); reverse_left_right(o1$4); @@ -1933,7 +1933,7 @@ function process_collision(dir, c1, c2, state) { } break; case "RKoopaShell" : - if (typeof t2$3 === "string") { + if (typeof t2$3 !== "object") { if (t2$3 === "Brick") { dec_health(o2$6); reverse_left_right(o1$4); diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 80e1c44f9e..77502cdf8f 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -293,7 +293,7 @@ function compare(param, param$1) { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -314,11 +314,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -332,7 +332,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -350,7 +350,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -364,7 +364,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -375,7 +375,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -485,7 +485,7 @@ function from_char(param) { } function height$1(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -494,9 +494,9 @@ function height$1(param) { function create$1(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -507,11 +507,11 @@ function create$1(l, v, r) { function bal$1(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -524,7 +524,7 @@ function bal$1(l, v, r) { if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, create$1(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create$1(create$1(ll, lv, lr.l), lr.v, create$1(lr.r, v, r)); } throw { @@ -541,7 +541,7 @@ function bal$1(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -554,7 +554,7 @@ function bal$1(l, v, r) { if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create$1(create$1(l, v, rl.l), rl.v, create$1(rl.r, rv, rr)); } throw { @@ -565,7 +565,7 @@ function bal$1(l, v, r) { } function add$1(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -710,7 +710,7 @@ function seq$1(ids, kind, x, y) { var match = x.def; var match$1 = y.def; var exit = 0; - if (typeof match === "string") { + if (typeof match !== "object") { return y; } if (match.TAG === "Alt") { @@ -722,7 +722,7 @@ function seq$1(ids, kind, x, y) { exit = 2; } if (exit === 2) { - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { if (kind === "First") { return x; } @@ -742,7 +742,7 @@ function seq$1(ids, kind, x, y) { function is_eps(expr) { var match = expr.def; - if (typeof match === "string") { + if (typeof match !== "object") { return true; } else { return false; @@ -768,7 +768,7 @@ function erase(ids, m, m$p) { function rename(ids, x) { var l = x.def; - if (typeof l === "string") { + if (typeof l !== "object") { return mk_expr(ids, x.def); } switch (l.TAG) { @@ -910,7 +910,7 @@ function tseq(kind, x, y, rem) { switch (match.TAG) { case "TExp" : var tmp = match._1.def; - if (typeof tmp === "string" && !x.tl) { + if (typeof tmp !== "object" && !x.tl) { return { hd: { TAG: "TExp", @@ -1105,7 +1105,7 @@ function remove_duplicates(prev, _l, y) { case "TExp" : var x$2 = x._1; var tmp = x$2.def; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { var r = l.tl; if (List.memq(y.id, prev)) { _l = r; @@ -1205,7 +1205,7 @@ function filter_marks(b, e, marks) { function delta_1(marks, c, next_cat, prev_cat, x, rem) { var s = x.def; - if (typeof s === "string") { + if (typeof s !== "object") { return { hd: { TAG: "TMatch", @@ -1499,7 +1499,7 @@ var unknown_state = { function mk_state(ncol, desc) { var match = status(desc); var break_state; - break_state = typeof match === "string" && match !== "Failed" ? false : true; + break_state = typeof match !== "object" && match !== "Failed" ? false : true; return { idx: break_state ? -3 : desc.idx, real_idx: desc.idx, @@ -1724,7 +1724,7 @@ function trans_set(cache, cm, s) { var _param = cache.contents; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1754,7 +1754,7 @@ function trans_set(cache, cm, s) { function is_charset(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } switch (param.TAG) { @@ -1843,7 +1843,7 @@ function colorize(c, regexp) { var colorize$1 = function (_regexp) { while(true) { var regexp = _regexp; - if (typeof regexp === "string") { + if (typeof regexp !== "object") { switch (regexp) { case "Beg_of_line" : case "End_of_line" : @@ -1928,64 +1928,64 @@ function equal$2(_x1, _x2) { while(true) { var x2 = _x2; var x1 = _x1; - if (typeof x1 === "string") { + if (typeof x1 !== "object") { switch (x1) { case "Beg_of_line" : - if (typeof x2 === "string" && x2 === "Beg_of_line") { + if (typeof x2 !== "object" && x2 === "Beg_of_line") { return true; } else { return false; } case "End_of_line" : - if (typeof x2 === "string" && x2 === "End_of_line") { + if (typeof x2 !== "object" && x2 === "End_of_line") { return true; } else { return false; } case "Beg_of_word" : - if (typeof x2 === "string" && x2 === "Beg_of_word") { + if (typeof x2 !== "object" && x2 === "Beg_of_word") { return true; } else { return false; } case "End_of_word" : - if (typeof x2 === "string" && x2 === "End_of_word") { + if (typeof x2 !== "object" && x2 === "End_of_word") { return true; } else { return false; } case "Not_bound" : - if (typeof x2 === "string" && x2 === "Not_bound") { + if (typeof x2 !== "object" && x2 === "Not_bound") { return true; } else { return false; } case "Beg_of_str" : - if (typeof x2 === "string" && x2 === "Beg_of_str") { + if (typeof x2 !== "object" && x2 === "Beg_of_str") { return true; } else { return false; } case "End_of_str" : - if (typeof x2 === "string" && x2 === "End_of_str") { + if (typeof x2 !== "object" && x2 === "End_of_str") { return true; } else { return false; } case "Last_end_of_line" : - if (typeof x2 === "string" && x2 === "Last_end_of_line") { + if (typeof x2 !== "object" && x2 === "Last_end_of_line") { return true; } else { return false; } case "Start" : - if (typeof x2 === "string" && x2 === "Start") { + if (typeof x2 !== "object" && x2 === "Start") { return true; } else { return false; } case "Stop" : - if (typeof x2 === "string" && x2 === "Stop") { + if (typeof x2 !== "object" && x2 === "Stop") { return true; } else { return false; @@ -1995,25 +1995,25 @@ function equal$2(_x1, _x2) { } else { switch (x1.TAG) { case "Set" : - if (typeof x2 === "string" || x2.TAG !== "Set") { + if (typeof x2 !== "object" || x2.TAG !== "Set") { return false; } else { return Caml_obj.equal(x1._0, x2._0); } case "Sequence" : - if (typeof x2 === "string" || x2.TAG !== "Sequence") { + if (typeof x2 !== "object" || x2.TAG !== "Sequence") { return false; } else { return eq_list(x1._0, x2._0); } case "Alternative" : - if (typeof x2 === "string" || x2.TAG !== "Alternative") { + if (typeof x2 !== "object" || x2.TAG !== "Alternative") { return false; } else { return eq_list(x1._0, x2._0); } case "Repeat" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Repeat") { @@ -2029,7 +2029,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Sem" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Sem") { @@ -2042,7 +2042,7 @@ function equal$2(_x1, _x2) { _x1 = x1._1; continue ; case "Sem_greedy" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Sem_greedy") { @@ -2057,7 +2057,7 @@ function equal$2(_x1, _x2) { case "Group" : return false; case "No_group" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "No_group") { @@ -2067,7 +2067,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Nest" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Nest") { @@ -2077,7 +2077,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Case" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Case") { @@ -2087,7 +2087,7 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "No_case" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "No_case") { @@ -2097,19 +2097,19 @@ function equal$2(_x1, _x2) { _x1 = x1._0; continue ; case "Intersection" : - if (typeof x2 === "string" || x2.TAG !== "Intersection") { + if (typeof x2 !== "object" || x2.TAG !== "Intersection") { return false; } else { return eq_list(x1._0, x2._0); } case "Complement" : - if (typeof x2 === "string" || x2.TAG !== "Complement") { + if (typeof x2 !== "object" || x2.TAG !== "Complement") { return false; } else { return eq_list(x1._0, x2._0); } case "Difference" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Difference") { @@ -2122,7 +2122,7 @@ function equal$2(_x1, _x2) { _x1 = x1._1; continue ; case "Pmark" : - if (typeof x2 === "string") { + if (typeof x2 !== "object") { return false; } if (x2.TAG !== "Pmark") { @@ -2181,7 +2181,7 @@ function merge_sequences(_param) { return /* [] */0; } var l$p = param.hd; - if (typeof l$p !== "string") { + if (typeof l$p === "object") { switch (l$p.TAG) { case "Sequence" : var match = l$p._0; @@ -2192,7 +2192,7 @@ function merge_sequences(_param) { var exit = 0; if (r$p) { var match$1 = r$p.hd; - if (typeof match$1 === "string" || match$1.TAG !== "Sequence") { + if (typeof match$1 !== "object" || match$1.TAG !== "Sequence") { exit = 2; } else { var match$2 = match$1._0; @@ -2271,7 +2271,7 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _s) var s = _s; var greedy = _greedy; var ign_group = _ign_group; - if (typeof s === "string") { + if (typeof s !== "object") { switch (s) { case "Beg_of_line" : var c$1 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.newline); @@ -2556,7 +2556,7 @@ function case_insens(s) { } function as_set(s) { - if (typeof s === "string") { + if (typeof s !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -2585,7 +2585,7 @@ function handle_case(_ign_case, _s) { while(true) { var s = _s; var ign_case = _ign_case; - if (typeof s === "string") { + if (typeof s !== "object") { return s; } switch (s.TAG) { @@ -2731,7 +2731,7 @@ function handle_case(_ign_case, _s) { function anchored(_l) { while(true) { var l = _l; - if (typeof l === "string") { + if (typeof l !== "object") { switch (l) { case "Beg_of_str" : case "Start" : @@ -3241,7 +3241,7 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { } res = match[1]; } - if (typeof res === "string") { + if (typeof res !== "object") { if (res === "Failed") { return "Failed"; } else { @@ -4194,7 +4194,7 @@ function re(flagsOpt, pat) { function exec(rex, pos, s) { var len; var substr = exec_internal("Re.exec", pos, len, true, rex, s); - if (typeof substr !== "string") { + if (typeof substr === "object") { return substr._0; } if (substr === "Failed") { diff --git a/jscomp/test/offset.js b/jscomp/test/offset.js index 0b26ec4875..20aa7f4842 100644 --- a/jscomp/test/offset.js +++ b/jscomp/test/offset.js @@ -7,7 +7,7 @@ var $$String = require("../../lib/js/string.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -16,9 +16,9 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -29,11 +29,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -46,7 +46,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -63,7 +63,7 @@ function bal(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -76,7 +76,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -87,7 +87,7 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -128,7 +128,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -136,7 +136,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -144,11 +144,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -164,14 +164,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -182,11 +182,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -197,14 +197,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -215,11 +215,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -228,7 +228,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -236,7 +236,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -244,9 +244,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -254,7 +254,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -289,7 +289,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -299,7 +299,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.string_compare(x, param.v); @@ -312,7 +312,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -320,9 +320,9 @@ function remove(x, t) { var l = t.l; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -345,12 +345,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -370,10 +370,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -389,10 +389,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -411,7 +411,7 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -430,14 +430,14 @@ function compare(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -458,13 +458,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -506,7 +506,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -520,7 +520,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -532,7 +532,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -549,7 +549,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -564,7 +564,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -585,7 +585,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -613,7 +613,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -624,7 +624,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -643,7 +643,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -662,7 +662,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -675,7 +675,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -696,7 +696,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -706,7 +706,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -727,7 +727,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -740,7 +740,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -761,7 +761,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -771,7 +771,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -792,7 +792,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -806,7 +806,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/jscomp/test/option_repr_test.js b/jscomp/test/option_repr_test.js index 860861ffb1..26ad266f17 100644 --- a/jscomp/test/option_repr_test.js +++ b/jscomp/test/option_repr_test.js @@ -31,7 +31,7 @@ function f0(x) { } function f1(u) { - if (typeof u === "string") { + if (typeof u !== "object") { return 1; } else { return 0; diff --git a/jscomp/test/pq_test.js b/jscomp/test/pq_test.js index cdca5868fe..b01d3d8206 100644 --- a/jscomp/test/pq_test.js +++ b/jscomp/test/pq_test.js @@ -3,7 +3,7 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); function insert(queue, prio, elt) { - if (typeof queue === "string") { + if (typeof queue !== "object") { return /* Node */{ _0: prio, _1: elt, @@ -35,7 +35,7 @@ function insert(queue, prio, elt) { var Queue_is_empty = /* @__PURE__ */Caml_exceptions.create("Pq_test.PrioQueue.Queue_is_empty"); function remove_top(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: Queue_is_empty, Error: new Error() @@ -43,10 +43,10 @@ function remove_top(param) { } var left = param._2; var tmp = param._3; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return left; } - if (typeof left === "string") { + if (typeof left !== "object") { return param._3; } var right = param._3; @@ -70,7 +70,7 @@ function remove_top(param) { } function extract(queue) { - if (typeof queue !== "string") { + if (typeof queue === "object") { return [ queue._0, queue._1, diff --git a/jscomp/test/rbset.js b/jscomp/test/rbset.js index 40601bcfa7..ea3b42383c 100644 --- a/jscomp/test/rbset.js +++ b/jscomp/test/rbset.js @@ -2,7 +2,7 @@ function blackify(s) { - if (typeof s === "string" || !s._0) { + if (typeof s !== "object" || !s._0) { return [ s, true @@ -21,7 +21,7 @@ function blackify(s) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -31,7 +31,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var y = param._2; @@ -56,12 +56,12 @@ function balance_left(l, x, r) { var c; var z; var d; - if (typeof l === "string" || !l._0) { + if (typeof l !== "object" || !l._0) { exit = 1; } else { var a$1 = l._1; var exit$1 = 0; - if (typeof a$1 === "string" || !a$1._0) { + if (typeof a$1 !== "object" || !a$1._0) { exit$1 = 3; } else { a = a$1._1; @@ -75,7 +75,7 @@ function balance_left(l, x, r) { } if (exit$1 === 3) { var match = l._3; - if (typeof match === "string" || !match._0) { + if (typeof match !== "object" || !match._0) { exit = 1; } else { a = a$1; @@ -128,12 +128,12 @@ function balance_right(l, x, r) { var c; var z; var d; - if (typeof r === "string" || !r._0) { + if (typeof r !== "object" || !r._0) { exit = 1; } else { var b$1 = r._1; var exit$1 = 0; - if (typeof b$1 === "string" || !b$1._0) { + if (typeof b$1 !== "object" || !b$1._0) { exit$1 = 3; } else { a = l; @@ -147,7 +147,7 @@ function balance_right(l, x, r) { } if (exit$1 === 3) { var match = r._3; - if (typeof match === "string" || !match._0) { + if (typeof match !== "object" || !match._0) { exit = 1; } else { a = l; @@ -201,10 +201,10 @@ function singleton(x) { } function unbalanced_left(param) { - if (typeof param !== "string") { + if (typeof param === "object") { if (param._0) { var match = param._1; - if (typeof match !== "string" && !match._0) { + if (typeof match === "object" && !match._0) { return [ balance_left(/* Node */{ _0: "Red", @@ -218,7 +218,7 @@ function unbalanced_left(param) { } else { var match$1 = param._1; - if (typeof match$1 !== "string") { + if (typeof match$1 === "object") { if (!match$1._0) { return [ balance_left(/* Node */{ @@ -231,7 +231,7 @@ function unbalanced_left(param) { ]; } var match$2 = match$1._3; - if (typeof match$2 !== "string" && !match$2._0) { + if (typeof match$2 === "object" && !match$2._0) { return [ /* Node */{ _0: "Black", @@ -264,10 +264,10 @@ function unbalanced_left(param) { } function unbalanced_right(param) { - if (typeof param !== "string") { + if (typeof param === "object") { if (param._0) { var match = param._3; - if (typeof match !== "string" && !match._0) { + if (typeof match === "object" && !match._0) { return [ balance_right(param._1, param._2, /* Node */{ _0: "Red", @@ -283,7 +283,7 @@ function unbalanced_right(param) { var match$1 = param._3; var x = param._2; var a = param._1; - if (typeof match$1 !== "string") { + if (typeof match$1 === "object") { if (!match$1._0) { return [ balance_right(a, x, /* Node */{ @@ -296,7 +296,7 @@ function unbalanced_right(param) { ]; } var match$2 = match$1._1; - if (typeof match$2 !== "string" && !match$2._0) { + if (typeof match$2 === "object" && !match$2._0) { return [ /* Node */{ _0: "Black", @@ -329,7 +329,7 @@ function unbalanced_right(param) { } function lbalance(x1, x2, x3) { - if (typeof x1 === "string") { + if (typeof x1 !== "object") { return /* Node */{ _0: "Black", _1: x1, @@ -347,7 +347,7 @@ function lbalance(x1, x2, x3) { } var r = x1._3; var l = x1._1; - if (typeof l !== "string" && l._0) { + if (typeof l === "object" && l._0) { return /* Node */{ _0: "Red", _1: /* Node */{ @@ -365,7 +365,7 @@ function lbalance(x1, x2, x3) { } }; } - if (typeof r === "string") { + if (typeof r !== "object") { return /* Node */{ _0: "Black", _1: x1, @@ -401,10 +401,10 @@ function lbalance(x1, x2, x3) { } function rbalance(x1, x2, x3) { - if (typeof x3 !== "string" && x3._0) { + if (typeof x3 === "object" && x3._0) { var b = x3._1; var exit = 0; - if (typeof b === "string") { + if (typeof b !== "object") { exit = 2; } else { if (b._0) { @@ -429,7 +429,7 @@ function rbalance(x1, x2, x3) { } if (exit === 2) { var match = x3._3; - if (typeof match !== "string" && match._0) { + if (typeof match === "object" && match._0) { return /* Node */{ _0: "Red", _1: /* Node */{ @@ -460,7 +460,7 @@ function rbalance(x1, x2, x3) { } function ins(x, s) { - if (typeof s === "string") { + if (typeof s !== "object") { return /* Node */{ _0: "Red", _1: "Empty", @@ -506,7 +506,7 @@ function ins(x, s) { function add(x, s) { var s$1 = ins(x, s); - if (typeof s$1 === "string" || !s$1._0) { + if (typeof s$1 !== "object" || !s$1._0) { return s$1; } else { return /* Node */{ @@ -519,7 +519,7 @@ function add(x, s) { } function remove_min(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -533,7 +533,7 @@ function remove_min(param) { var c = param._0; if (c) { var tmp = param._1; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return [ param._3, param._2, @@ -543,10 +543,10 @@ function remove_min(param) { } else { var tmp$1 = param._1; - if (typeof tmp$1 === "string") { + if (typeof tmp$1 !== "object") { var match = param._3; var x = param._2; - if (typeof match === "string") { + if (typeof match !== "object") { return [ "Empty", x, @@ -604,7 +604,7 @@ function remove_min(param) { } function remove_aux(x, n) { - if (typeof n === "string") { + if (typeof n !== "object") { return [ "Empty", false @@ -615,7 +615,7 @@ function remove_aux(x, n) { var l = n._1; var c = n._0; if (x === y) { - if (typeof r === "string") { + if (typeof r !== "object") { if (c === "Red") { return [ l, @@ -684,7 +684,7 @@ function remove(x, s) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (1 + cardinal(param._1) | 0) + cardinal(param._3) | 0; diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js index 1dafbab9ab..5d66f89151 100644 --- a/jscomp/test/rec_module_test.js +++ b/jscomp/test/rec_module_test.js @@ -95,7 +95,7 @@ var AAA = { }; function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -104,9 +104,9 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -117,11 +117,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -134,7 +134,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -151,7 +151,7 @@ function bal(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -164,7 +164,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -175,7 +175,7 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -216,7 +216,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -224,7 +224,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -232,11 +232,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -252,14 +252,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -270,11 +270,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -285,14 +285,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -303,11 +303,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -316,7 +316,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -324,7 +324,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -332,9 +332,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -342,7 +342,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -377,7 +377,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -387,7 +387,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(AAA.compare, x, param.v); @@ -400,7 +400,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -408,9 +408,9 @@ function remove(x, t) { var l = t.l; var c = Curry._2(AAA.compare, x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -433,12 +433,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -458,10 +458,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -477,10 +477,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -499,7 +499,7 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -518,14 +518,14 @@ function compare$1(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(AAA.compare, e1._0, e2._0); @@ -546,13 +546,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -594,7 +594,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -608,7 +608,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -620,7 +620,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -637,7 +637,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -652,7 +652,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -673,7 +673,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -701,7 +701,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -712,7 +712,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -731,7 +731,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -750,7 +750,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -763,7 +763,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -784,7 +784,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -794,7 +794,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -815,7 +815,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -828,7 +828,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -849,7 +849,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -859,7 +859,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -880,7 +880,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -894,7 +894,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/jscomp/test/record_extension_test.js b/jscomp/test/record_extension_test.js index bcf91beadc..bb4c201075 100644 --- a/jscomp/test/record_extension_test.js +++ b/jscomp/test/record_extension_test.js @@ -36,7 +36,7 @@ var v0 = { eq("File \"record_extension_test.ml\", line 19, characters 6-13", f(v0), 7); function f2(x) { - if (typeof x === "string" || x.TAG !== "C") { + if (typeof x !== "object" || x.TAG !== "C") { return 0; } else { return x.x; @@ -44,7 +44,7 @@ function f2(x) { } function f2_with(x) { - if (typeof x === "string" || x.TAG !== "C") { + if (typeof x !== "object" || x.TAG !== "C") { return x; } else { return { diff --git a/jscomp/test/recursive_records_test.js b/jscomp/test/recursive_records_test.js index 7c2d08cc55..034bda5f33 100644 --- a/jscomp/test/recursive_records_test.js +++ b/jscomp/test/recursive_records_test.js @@ -55,7 +55,7 @@ function f2(x) { } function hd(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return 0; } else { return x.content; @@ -63,7 +63,7 @@ function hd(x) { } function tl_exn(x) { - if (typeof x !== "string") { + if (typeof x === "object") { return x.next; } throw { diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index 2e9a6fe7b5..abf0485ba1 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -9,7 +9,7 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -23,7 +23,7 @@ function cons_enum(_s, _e) { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._3; @@ -33,14 +33,14 @@ function height(param) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._1; } _param = l; @@ -51,14 +51,14 @@ function min_elt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._2; - if (typeof r === "string") { + if (typeof r !== "object") { return param._1; } _param = r; @@ -67,7 +67,7 @@ function max_elt(_param) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -78,7 +78,7 @@ function cardinal_aux(_acc, _param) { while(true) { var param = _param; var acc = _acc; - if (typeof param === "string") { + if (typeof param !== "object") { return acc; } _param = param._0; @@ -95,7 +95,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param._0; @@ -114,7 +114,7 @@ function elements(s) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param._0); @@ -128,7 +128,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s._1, fold(f, s._0, accu)); @@ -140,7 +140,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param._1)) { @@ -157,7 +157,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param._1)) { @@ -198,7 +198,7 @@ var Height_invariant_broken = /* @__PURE__ */Caml_exceptions.create("Set_gen.Hei var Height_diff_borken = /* @__PURE__ */Caml_exceptions.create("Set_gen.Height_diff_borken"); function check_height_and_diff(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } var h = param._3; @@ -226,9 +226,9 @@ function check(tree) { function create(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l._3; + hl = typeof l !== "object" ? 0 : l._3; var hr; - hr = typeof r === "string" ? 0 : r._3; + hr = typeof r !== "object" ? 0 : r._3; return /* Node */{ _0: l, _1: v, @@ -239,11 +239,11 @@ function create(l, v, r) { function internal_bal(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l._3; + hl = typeof l !== "object" ? 0 : l._3; var hr; - hr = typeof r === "string" ? 0 : r._3; + hr = typeof r !== "object" ? 0 : r._3; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -260,7 +260,7 @@ function internal_bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } throw { @@ -281,7 +281,7 @@ function internal_bal(l, v, r) { _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -298,7 +298,7 @@ function internal_bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } throw { @@ -313,7 +313,7 @@ function internal_bal(l, v, r) { } function remove_min_elt(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -321,7 +321,7 @@ function remove_min_elt(param) { }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._2; } else { return internal_bal(remove_min_elt(l), param._1, param._2); @@ -338,9 +338,9 @@ function singleton(x) { } function internal_merge(l, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return internal_bal(l, min_elt(r), remove_min_elt(r)); @@ -348,7 +348,7 @@ function internal_merge(l, r) { } function add_min_element(v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(v); } else { return internal_bal(add_min_element(v, param._0), param._1, param._2); @@ -356,7 +356,7 @@ function add_min_element(v, param) { } function add_max_element(v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(v); } else { return internal_bal(param._0, param._1, add_max_element(v, param._2)); @@ -364,11 +364,11 @@ function add_max_element(v, param) { } function internal_join(l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l._3; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r._3; @@ -382,9 +382,9 @@ function internal_join(l, v, r) { } function internal_concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return internal_join(t1, min_elt(t2), remove_min_elt(t2)); @@ -392,7 +392,7 @@ function internal_concat(t1, t2) { } function filter(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param._1; @@ -407,7 +407,7 @@ function filter(p, param) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -596,7 +596,7 @@ function of_sorted_array(l) { function is_ordered(cmp, tree) { var is_ordered_min_max = function (tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return "Empty"; } var r = tree._2; @@ -675,14 +675,14 @@ function compare_aux(cmp, _e1, _e2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(cmp, e1._0, e2._0); diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index f375fe33a2..d87f52b90e 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -7,7 +7,7 @@ var $$String = require("../../lib/js/string.js"); var Set_gen = require("./set_gen.js"); function split(x, tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return [ "Empty", false, @@ -42,7 +42,7 @@ function split(x, tree) { } function add(x, tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -64,12 +64,12 @@ function add(x, tree) { } function union(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1._3; var v1 = s1._1; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2._3; @@ -89,10 +89,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1._2; @@ -108,10 +108,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1._2; @@ -129,7 +129,7 @@ function diff(s1, s2) { function mem(x, _tree) { while(true) { var tree = _tree; - if (typeof tree === "string") { + if (typeof tree !== "object") { return false; } var c = Caml.string_compare(x, tree._1); @@ -142,7 +142,7 @@ function mem(x, _tree) { } function remove(x, tree) { - if (typeof tree === "string") { + if (typeof tree !== "object") { return "Empty"; } var r = tree._2; @@ -170,13 +170,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1._2; var v1 = s1._1; var l1 = s1._0; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2._2; @@ -218,7 +218,7 @@ function subset(_s1, _s2) { function find(x, _tree) { while(true) { var tree = _tree; - if (typeof tree === "string") { + if (typeof tree !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index 4ab731c177..e69e9d3774 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -19,7 +19,7 @@ function cons(x, y) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Nil"; } else { return /* Cons */{ diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index a3fb89b395..136e23d200 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -42,7 +42,7 @@ function cons(x, y) { } function length(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return 0; } else { return 1 + length(x._1) | 0; @@ -50,7 +50,7 @@ function length(x) { } function map(f, x) { - if (typeof x === "string") { + if (typeof x !== "object") { return "Nil"; } else { return /* Cons */{ diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 30936c384a..054ba70ac8 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); var Caml_option = require("../../lib/js/caml_option.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -36,11 +36,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -54,7 +54,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -72,7 +72,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -86,7 +86,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -97,7 +97,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -105,7 +105,7 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -151,7 +151,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -169,7 +169,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -184,7 +184,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -209,7 +209,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -221,7 +221,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -246,7 +246,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -261,7 +261,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -286,7 +286,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -298,7 +298,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -323,7 +323,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Caml.int_compare(x, param.v); @@ -338,7 +338,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.int_compare(x, param.v); @@ -353,14 +353,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -374,11 +374,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -392,14 +392,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -413,11 +413,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -429,7 +429,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -437,7 +437,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -445,10 +445,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -456,7 +456,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -484,7 +484,7 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -540,7 +540,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -551,7 +551,7 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -567,7 +567,7 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -587,7 +587,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -599,7 +599,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -616,7 +616,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -631,7 +631,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -639,7 +639,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -647,11 +647,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -665,10 +665,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -684,7 +684,7 @@ function concat_or_join(t1, v, d, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -720,8 +720,8 @@ function split(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -733,7 +733,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -750,12 +750,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -783,7 +783,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -805,7 +805,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -837,7 +837,7 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -857,14 +857,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.int_compare(e1._0, e2._0); @@ -887,14 +887,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (e1._0 !== e2._0) { @@ -910,7 +910,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -921,7 +921,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/jscomp/test/test_int_map_find.js b/jscomp/test/test_int_map_find.js index 1c819a403c..fb92531eea 100644 --- a/jscomp/test/test_int_map_find.js +++ b/jscomp/test/test_int_map_find.js @@ -4,7 +4,7 @@ var Caml = require("../../lib/js/caml.js"); var List = require("../../lib/js/list.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -25,11 +25,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -43,7 +43,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -61,7 +61,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -75,7 +75,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -86,7 +86,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index f95985cf9c..662c03c46c 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -5,7 +5,7 @@ var Curry = require("../../lib/js/curry.js"); function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param._3; @@ -13,9 +13,9 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l._3; + hl = typeof l !== "object" ? 0 : l._3; var hr; - hr = typeof r === "string" ? 0 : r._3; + hr = typeof r !== "object" ? 0 : r._3; return /* Node */{ _0: l, _1: v, @@ -25,11 +25,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l._3; + hl = typeof l !== "object" ? 0 : l._3; var hr; - hr = typeof r === "string" ? 0 : r._3; + hr = typeof r !== "object" ? 0 : r._3; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -42,7 +42,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } throw { @@ -59,7 +59,7 @@ function Make(Ord) { _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -72,7 +72,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } throw { @@ -82,7 +82,7 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ _0: "Empty", _1: x, @@ -111,25 +111,25 @@ function Make(Ord) { }; }; var add_min_element = function (v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(v); } else { return bal(add_min_element(v, param._0), param._1, param._2); } }; var add_max_element = function (v, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(v); } else { return bal(param._0, param._1, add_max_element(v, param._2)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l._3; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r._3; @@ -144,14 +144,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._1; } _param = l; @@ -161,14 +161,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param._2; - if (typeof r === "string") { + if (typeof r !== "object") { return param._1; } _param = r; @@ -176,7 +176,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -184,32 +184,32 @@ function Make(Ord) { }; } var l = param._0; - if (typeof l === "string") { + if (typeof l !== "object") { return param._2; } else { return bal(remove_min_elt(l), param._1, param._2); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -243,7 +243,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -252,7 +252,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param._1); @@ -264,7 +264,7 @@ function Make(Ord) { }; }; var remove = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var r = param._2; @@ -280,12 +280,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1._3; var v1 = s1._1; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2._3; @@ -304,10 +304,10 @@ function Make(Ord) { return join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1._2; @@ -322,10 +322,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1._2; @@ -343,7 +343,7 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -359,14 +359,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -388,13 +388,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1._2; var v1 = s1._1; var l1 = s1._0; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2._2; @@ -435,7 +435,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param._0); @@ -448,7 +448,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s._1, fold(f, s._0, accu)); @@ -459,7 +459,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param._1)) { @@ -475,7 +475,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param._1)) { @@ -489,7 +489,7 @@ function Make(Ord) { }; }; var filter = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param._1; @@ -503,7 +503,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -530,7 +530,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param._0) + 1 | 0) + cardinal(param._2) | 0; @@ -540,7 +540,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param._0; @@ -557,7 +557,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index 6b0af6d8aa..f75bc6435a 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -4,7 +4,7 @@ var Caml = require("../../lib/js/caml.js"); var Curry = require("../../lib/js/curry.js"); function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -25,11 +25,11 @@ function create(l, x, d, r) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -43,7 +43,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -61,7 +61,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -75,7 +75,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -86,7 +86,7 @@ function bal(l, x, d, r) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -132,7 +132,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/jscomp/test/test_switch.js b/jscomp/test/test_switch.js index 7ac9a0dcb8..7aa9544cf0 100644 --- a/jscomp/test/test_switch.js +++ b/jscomp/test/test_switch.js @@ -3,7 +3,7 @@ var Curry = require("../../lib/js/curry.js"); function f(param) { - if (typeof param === "string") { + if (typeof param !== "object") { if (param === "G") { return 4; } else { diff --git a/jscomp/test/test_trywith.js b/jscomp/test/test_trywith.js index 6780759f26..2965f2da53 100644 --- a/jscomp/test/test_trywith.js +++ b/jscomp/test/test_trywith.js @@ -123,7 +123,7 @@ function u(param) { } function f(x) { - if (typeof x === "string") { + if (typeof x !== "object") { return 2; } if (x.TAG === "D") { diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index ffc33f3b14..ac5b5b020c 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -67,7 +67,7 @@ var Util = { }; function string_of_rank(i) { - if (typeof i === "string") { + if (typeof i !== "object") { if (i === "Uninitialized") { return "Uninitialized"; } else { @@ -87,7 +87,7 @@ function find_ticker_by_name(all_tickers, ticker) { function print_all_composite(all_tickers) { List.iter((function (param) { var tmp = param.type_; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return ; } console.log(param.ticker_name); @@ -95,7 +95,7 @@ function print_all_composite(all_tickers) { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -126,11 +126,11 @@ function singleton(x, d) { function bal(l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -144,7 +144,7 @@ function bal(l, x, d, r) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -162,7 +162,7 @@ function bal(l, x, d, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -176,7 +176,7 @@ function bal(l, x, d, r) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -187,7 +187,7 @@ function bal(l, x, d, r) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -195,7 +195,7 @@ function is_empty(param) { } function add(x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -241,7 +241,7 @@ function add(x, data, m) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -259,7 +259,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -274,7 +274,7 @@ function find_first(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -299,7 +299,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -311,7 +311,7 @@ function find_first_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -336,7 +336,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -351,7 +351,7 @@ function find_last(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -376,7 +376,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -388,7 +388,7 @@ function find_last_opt(f, _param) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -413,7 +413,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Caml_obj.compare(x, param.v); @@ -428,7 +428,7 @@ function find_opt(x, _param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml_obj.compare(x, param.v); @@ -443,14 +443,14 @@ function mem(x, _param) { function min_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -464,11 +464,11 @@ function min_binding(_param) { function min_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -482,14 +482,14 @@ function min_binding_opt(_param) { function max_binding(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -503,11 +503,11 @@ function max_binding(_param) { function max_binding_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -519,7 +519,7 @@ function max_binding_opt(_param) { } function remove_min_binding(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -527,7 +527,7 @@ function remove_min_binding(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); @@ -535,10 +535,10 @@ function remove_min_binding(param) { } function merge(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -546,7 +546,7 @@ function merge(t1, t2) { } function remove(x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -574,7 +574,7 @@ function remove(x, m) { } function update(x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -630,7 +630,7 @@ function update(x, f, m) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -641,7 +641,7 @@ function iter(f, _param) { } function map(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -657,7 +657,7 @@ function map(f, param) { } function mapi(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -677,7 +677,7 @@ function fold(f, _m, _accu) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -689,7 +689,7 @@ function fold(f, _m, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -706,7 +706,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -721,7 +721,7 @@ function exists(p, _param) { } function add_min_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); @@ -729,7 +729,7 @@ function add_min_binding(k, x, param) { } function add_max_binding(k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); @@ -737,11 +737,11 @@ function add_max_binding(k, x, param) { } function join(l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -755,10 +755,10 @@ function join(l, v, d, r) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -774,7 +774,7 @@ function concat_or_join(t1, v, d, t2) { } function split$1(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -810,8 +810,8 @@ function split$1(x, param) { } function merge$1(f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -823,7 +823,7 @@ function merge$1(f, s1, s2) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -840,12 +840,12 @@ function merge$1(f, s1, s2) { } function union(f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -873,7 +873,7 @@ function union(f, s1, s2) { } function filter(p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -895,7 +895,7 @@ function filter(p, m) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -927,7 +927,7 @@ function cons_enum(_m, _e) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -947,14 +947,14 @@ function compare(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml_obj.compare(e1._0, e2._0); @@ -977,14 +977,14 @@ function equal(cmp, m1, m2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (!Caml_obj.equal(e1._0, e2._0)) { @@ -1000,7 +1000,7 @@ function equal(cmp, m1, m2) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1011,7 +1011,7 @@ function bindings_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -1071,7 +1071,7 @@ function compute_update_sequences(all_tickers) { List.fold_left((function (counter, ticker) { var loop = function (counter, ticker) { var rank = ticker.rank; - if (typeof rank !== "string") { + if (typeof rank === "object") { return counter; } if (rank !== "Uninitialized") { @@ -1079,7 +1079,7 @@ function compute_update_sequences(all_tickers) { } ticker.rank = "Visited"; var match = ticker.type_; - if (typeof match === "string") { + if (typeof match !== "object") { var counter$1 = counter + 1 | 0; ticker.rank = /* Ranked */{ _0: counter$1 @@ -1099,7 +1099,7 @@ function compute_update_sequences(all_tickers) { }), 0, all_tickers); var map = List.fold_left((function (map, ticker) { var tmp = ticker.type_; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return add(ticker.ticker_name, { hd: ticker, tl: /* [] */0 @@ -1112,7 +1112,7 @@ function compute_update_sequences(all_tickers) { var up = _up; var type_ = ticker.type_; var ticker_name = ticker.ticker_name; - if (typeof type_ === "string") { + if (typeof type_ !== "object") { var l = find(ticker_name, map); return add(ticker_name, Pervasives.$at(up, l), map); } @@ -1135,7 +1135,7 @@ function compute_update_sequences(all_tickers) { return fold((function (k, l, map) { var l$1 = List.sort_uniq((function (lhs, rhs) { var x = lhs.rank; - if (typeof x === "string") { + if (typeof x !== "object") { if (x === "Uninitialized") { throw { RE_EXN_ID: "Failure", @@ -1150,7 +1150,7 @@ function compute_update_sequences(all_tickers) { }; } else { var y = rhs.rank; - if (typeof y !== "string") { + if (typeof y === "object") { return Caml.int_compare(x._0, y._0); } if (y === "Uninitialized") { @@ -1175,7 +1175,7 @@ function process_quote(ticker_map, new_ticker, new_value) { var update_sequence = find(new_ticker, ticker_map); List.iter((function (ticker) { var match = ticker.type_; - if (typeof match === "string") { + if (typeof match !== "object") { if (ticker.ticker_name === new_ticker) { ticker.value = new_value; return ; diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index d47fcc995b..c6c27954cf 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -451,7 +451,7 @@ if (!Caml_obj.equal(unsafe_topsort(grwork), { } function height(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -460,9 +460,9 @@ function height(param) { function create(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -473,11 +473,11 @@ function create(l, v, r) { function bal(l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -490,7 +490,7 @@ function bal(l, v, r) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -507,7 +507,7 @@ function bal(l, v, r) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -520,7 +520,7 @@ function bal(l, v, r) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -531,7 +531,7 @@ function bal(l, v, r) { } function add(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -572,7 +572,7 @@ function singleton(x) { } function add_min_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); @@ -580,7 +580,7 @@ function add_min_element(x, param) { } function add_max_element(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); @@ -588,11 +588,11 @@ function add_max_element(x, param) { } function join(l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -608,14 +608,14 @@ function join(l, v, r) { function min_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -626,11 +626,11 @@ function min_elt(_param) { function min_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -641,14 +641,14 @@ function min_elt_opt(_param) { function max_elt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -659,11 +659,11 @@ function max_elt(_param) { function max_elt_opt(_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -672,7 +672,7 @@ function max_elt_opt(_param) { } function remove_min_elt(param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -680,7 +680,7 @@ function remove_min_elt(param) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); @@ -688,9 +688,9 @@ function remove_min_elt(param) { } function concat(t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); @@ -698,7 +698,7 @@ function concat(t1, t2) { } function split(x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -733,7 +733,7 @@ function split(x, param) { } function is_empty(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -743,7 +743,7 @@ function is_empty(param) { function mem(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Caml.string_compare(x, param.v); @@ -756,7 +756,7 @@ function mem(x, _param) { } function remove(x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -764,9 +764,9 @@ function remove(x, t) { var l = t.l; var c = Caml.string_compare(x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -789,12 +789,12 @@ function remove(x, t) { } function union(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -814,10 +814,10 @@ function union(s1, s2) { } function inter(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -833,10 +833,10 @@ function inter(s1, s2) { } function diff(s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -855,7 +855,7 @@ function cons_enum(_s, _e) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -874,14 +874,14 @@ function compare(s1, s2) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Caml.string_compare(e1._0, e2._0); @@ -902,13 +902,13 @@ function subset(_s1, _s2) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -950,7 +950,7 @@ function subset(_s1, _s2) { function iter(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -964,7 +964,7 @@ function fold(f, _s, _accu) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -976,7 +976,7 @@ function fold(f, _s, _accu) { function for_all(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -993,7 +993,7 @@ function for_all(p, _param) { function exists(p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -1008,7 +1008,7 @@ function exists(p, _param) { } function filter(p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -1029,7 +1029,7 @@ function filter(p, t) { } function partition(p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -1057,7 +1057,7 @@ function partition(p, param) { } function cardinal(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1068,7 +1068,7 @@ function elements_aux(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -1087,7 +1087,7 @@ function elements(s) { function find(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1106,7 +1106,7 @@ function find(x, _param) { function find_first(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1119,7 +1119,7 @@ function find_first(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -1140,7 +1140,7 @@ function find_first(f, _param) { function find_first_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1150,7 +1150,7 @@ function find_first_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -1171,7 +1171,7 @@ function find_first_opt(f, _param) { function find_last(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1184,7 +1184,7 @@ function find_last(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -1205,7 +1205,7 @@ function find_last(f, _param) { function find_last_opt(f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1215,7 +1215,7 @@ function find_last_opt(f, _param) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -1236,7 +1236,7 @@ function find_last_opt(f, _param) { function find_opt(x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1250,7 +1250,7 @@ function find_opt(x, _param) { } function map(f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/jscomp/test/typeof_test.js b/jscomp/test/typeof_test.js index 2853962abc..2a9808d982 100644 --- a/jscomp/test/typeof_test.js +++ b/jscomp/test/typeof_test.js @@ -5,7 +5,7 @@ var Js_types = require("../../lib/js/js_types.js"); function string_or_number(x) { var ty = Js_types.classify(x); - if (typeof ty === "string") { + if (typeof ty !== "object") { switch (ty) { case "JSFalse" : case "JSTrue" : diff --git a/jscomp/test/utf8_decode_test.js b/jscomp/test/utf8_decode_test.js index dcf4c2635c..554061f0f1 100644 --- a/jscomp/test/utf8_decode_test.js +++ b/jscomp/test/utf8_decode_test.js @@ -60,7 +60,7 @@ function utf8_decode(strm) { } Stream.junk(strm); var c = classify(chr); - if (typeof c === "string") { + if (typeof c !== "object") { throw { RE_EXN_ID: Stream.$$Error, _1: "Invalid byte", @@ -85,7 +85,7 @@ function utf8_decode(strm) { return c; } var cc = classify(Stream.next(strm)); - if (typeof cc === "string") { + if (typeof cc !== "object") { throw { RE_EXN_ID: Stream.$$Error, _1: "Continuation byte expected", @@ -129,7 +129,7 @@ function utf8_list(s) { function decode(bytes, offset) { var c = classify(Caml_bytes.get(bytes, offset)); - if (typeof c === "string") { + if (typeof c !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "decode", @@ -163,7 +163,7 @@ function decode(bytes, offset) { ]; } var cc = classify(Caml_bytes.get(bytes, offset$1)); - if (typeof cc === "string") { + if (typeof cc !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "decode", diff --git a/jscomp/test/variant.js b/jscomp/test/variant.js index af4318e849..afc72b427a 100644 --- a/jscomp/test/variant.js +++ b/jscomp/test/variant.js @@ -6,7 +6,7 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); var Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function foo(n) { - if (typeof n === "string") { + if (typeof n !== "object") { if (n === "A1") { return 1; } else { @@ -26,7 +26,7 @@ function foo(n) { } function fooA1(param) { - if (typeof param === "string" && param === "A1") { + if (typeof param !== "object" && param === "A1") { return 1; } else { return 42; @@ -34,7 +34,7 @@ function fooA1(param) { } function fooC(param) { - if (typeof param === "string" || param.TAG !== "C") { + if (typeof param !== "object" || param.TAG !== "C") { return 42; } else { return param._0 + param._1 | 0; diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index e44aa3eca9..0f01f32e67 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -68,7 +68,7 @@ function not_(x) { } function st(state) { - if (typeof state === "string") { + if (typeof state !== "object") { return 0; } else { return 23; @@ -76,7 +76,7 @@ function st(state) { } function showToJs(x) { - if (typeof x === "string" && x === "No") { + if (typeof x !== "object" && x === "No") { return false; } else { return true; @@ -106,28 +106,28 @@ function third(l) { } function third2(l) { - if (typeof l === "string") { + if (typeof l !== "object") { return false; } if (l._0 !== 1) { return false; } var match = l._1; - if (typeof match === "string") { + if (typeof match !== "object") { return false; } if (match._0 !== 2) { return false; } var match$1 = match._1; - if (typeof match$1 === "string") { + if (typeof match$1 !== "object") { return false; } if (match$1._0 !== 3) { return false; } var tmp = match$1._1; - if (typeof tmp === "string") { + if (typeof tmp !== "object") { return true; } else { return false; diff --git a/lib/es6/caml_module.js b/lib/es6/caml_module.js index 359609d41c..d7bbd0121d 100644 --- a/lib/es6/caml_module.js +++ b/lib/es6/caml_module.js @@ -11,7 +11,7 @@ function init_mod(loc, shape) { }; }; var loop = function (shape, struct_, idx) { - if (typeof shape === "string") { + if (typeof shape !== "object") { switch (shape) { case "Function" : struct_[idx] = undef_module; @@ -56,7 +56,7 @@ function init_mod(loc, shape) { function update_mod(shape, o, n) { var aux = function (shape, o, n, parent, i) { - if (typeof shape === "string") { + if (typeof shape !== "object") { switch (shape) { case "Function" : parent[i] = n; @@ -79,7 +79,7 @@ function update_mod(shape, o, n) { return ; } }; - if (typeof shape === "string") { + if (typeof shape !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index 8fdba4a319..26c224522f 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -92,7 +92,7 @@ function reset(h) { } function copy_bucketlist(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var key = param.key; @@ -102,7 +102,7 @@ function copy_bucketlist(param) { while(true) { var param = _param; var prec = _prec; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var key = param.key; @@ -113,7 +113,7 @@ function copy_bucketlist(param) { data: data, next: next }; - if (typeof prec === "string") { + if (typeof prec !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -166,7 +166,7 @@ function resize(indexfun, h) { var insert_bucket = function (_cell) { while(true) { var cell = _cell; - if (typeof cell === "string") { + if (typeof cell !== "object") { return ; } var key = cell.key; @@ -179,7 +179,7 @@ function resize(indexfun, h) { }); var nidx = Curry._2(indexfun, h, key); var tail = Caml_array.get(ndata_tail, nidx); - if (typeof tail === "string") { + if (typeof tail !== "object") { Caml_array.set(ndata, nidx, cell$1); } else { tail.next = cell$1; @@ -197,7 +197,7 @@ function resize(indexfun, h) { } for(var i$1 = 0; i$1 < nsize; ++i$1){ var tail = Caml_array.get(ndata_tail, i$1); - if (typeof tail !== "string") { + if (typeof tail === "object") { tail.next = "Empty"; } @@ -230,14 +230,14 @@ function remove(h, key) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Caml_obj.equal(k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -252,7 +252,7 @@ function remove(h, key) { function find(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -264,7 +264,7 @@ function find(h, key) { if (Caml_obj.equal(key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -276,7 +276,7 @@ function find(h, key) { if (Caml_obj.equal(key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -291,7 +291,7 @@ function find(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -311,7 +311,7 @@ function find(h, key) { function find_opt(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -320,7 +320,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -329,7 +329,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -341,7 +341,7 @@ function find_opt(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -360,7 +360,7 @@ function find_all(h, key) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -382,7 +382,7 @@ function find_all(h, key) { function replace_bucket(key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -420,7 +420,7 @@ function mem(h, key) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; @@ -437,7 +437,7 @@ function iter(f, h) { var do_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var key = param.key; @@ -476,8 +476,8 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { while(true) { var slot = _slot; var prec = _prec; - if (typeof slot === "string") { - if (typeof prec === "string") { + if (typeof slot !== "object") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, "Empty"); } else { prec.next = "Empty"; @@ -489,7 +489,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { var next = slot.next; var data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { - if (typeof prec === "string") { + if (typeof prec !== "object") { Caml_array.set(h.data, i, slot); } else { prec.next = slot; @@ -531,7 +531,7 @@ function fold(f, h, init) { while(true) { var accu = _accu; var b = _b; - if (typeof b === "string") { + if (typeof b !== "object") { return accu; } var key = b.key; @@ -570,7 +570,7 @@ function bucket_length(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } var next = param.next; @@ -622,14 +622,14 @@ function MakeSeeded(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -643,7 +643,7 @@ function MakeSeeded(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -655,7 +655,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -667,7 +667,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -682,7 +682,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -701,7 +701,7 @@ function MakeSeeded(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -710,7 +710,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -719,7 +719,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -731,7 +731,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -749,7 +749,7 @@ function MakeSeeded(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -770,7 +770,7 @@ function MakeSeeded(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -806,7 +806,7 @@ function MakeSeeded(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; @@ -864,14 +864,14 @@ function Make(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -885,7 +885,7 @@ function Make(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -897,7 +897,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -909,7 +909,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -924,7 +924,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -943,7 +943,7 @@ function Make(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -952,7 +952,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -961,7 +961,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -973,7 +973,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -991,7 +991,7 @@ function Make(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -1012,7 +1012,7 @@ function Make(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -1048,7 +1048,7 @@ function Make(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; diff --git a/lib/es6/map.js b/lib/es6/map.js index 349d22ba66..c89cf052bd 100644 --- a/lib/es6/map.js +++ b/lib/es6/map.js @@ -5,7 +5,7 @@ import * as Caml_option from "./caml_option.js"; function Make(funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -33,11 +33,11 @@ function Make(funarg) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -51,7 +51,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -69,7 +69,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +83,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -93,14 +93,14 @@ function Make(funarg) { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -145,7 +145,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -162,7 +162,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -177,7 +177,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -201,7 +201,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -213,7 +213,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -237,7 +237,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -252,7 +252,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -276,7 +276,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -288,7 +288,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -312,7 +312,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -326,7 +326,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -340,14 +340,14 @@ function Make(funarg) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -360,11 +360,11 @@ function Make(funarg) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -377,14 +377,14 @@ function Make(funarg) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -397,11 +397,11 @@ function Make(funarg) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -412,7 +412,7 @@ function Make(funarg) { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -420,24 +420,24 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -464,7 +464,7 @@ function Make(funarg) { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -519,7 +519,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -529,7 +529,7 @@ function Make(funarg) { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -544,7 +544,7 @@ function Make(funarg) { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -563,7 +563,7 @@ function Make(funarg) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -574,7 +574,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -590,7 +590,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -604,25 +604,25 @@ function Make(funarg) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -635,10 +635,10 @@ function Make(funarg) { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -652,7 +652,7 @@ function Make(funarg) { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -687,8 +687,8 @@ function Make(funarg) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -700,7 +700,7 @@ function Make(funarg) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -716,12 +716,12 @@ function Make(funarg) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -748,7 +748,7 @@ function Make(funarg) { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -769,7 +769,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -800,7 +800,7 @@ function Make(funarg) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -819,14 +819,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -848,14 +848,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -870,7 +870,7 @@ function Make(funarg) { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -880,7 +880,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/lib/es6/mapLabels.js b/lib/es6/mapLabels.js index 6b5b442156..2adefdf504 100644 --- a/lib/es6/mapLabels.js +++ b/lib/es6/mapLabels.js @@ -5,7 +5,7 @@ import * as Caml_option from "./caml_option.js"; function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -33,11 +33,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -51,7 +51,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -69,7 +69,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +83,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -93,14 +93,14 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -145,7 +145,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -164,7 +164,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -184,7 +184,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -203,7 +203,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -223,7 +223,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -239,7 +239,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -259,7 +259,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -278,7 +278,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -298,7 +298,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -312,7 +312,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(Ord.compare, x, param.v); @@ -326,7 +326,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -340,14 +340,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -360,11 +360,11 @@ function Make(Ord) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -377,14 +377,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -397,11 +397,11 @@ function Make(Ord) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -412,7 +412,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -420,24 +420,24 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -464,7 +464,7 @@ function Make(Ord) { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -519,7 +519,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -529,7 +529,7 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -544,7 +544,7 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -563,7 +563,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -574,7 +574,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -590,7 +590,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -604,25 +604,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -635,10 +635,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -652,7 +652,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -687,8 +687,8 @@ function Make(Ord) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -700,7 +700,7 @@ function Make(Ord) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -716,12 +716,12 @@ function Make(Ord) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -748,7 +748,7 @@ function Make(Ord) { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -769,7 +769,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -800,7 +800,7 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -819,14 +819,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -848,14 +848,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -870,7 +870,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -880,7 +880,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/lib/es6/moreLabels.js b/lib/es6/moreLabels.js index d3f63805c3..9162d0adb5 100644 --- a/lib/es6/moreLabels.js +++ b/lib/es6/moreLabels.js @@ -35,7 +35,7 @@ var Hashtbl = { var $$Map = { Make: (function (funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -63,11 +63,11 @@ var $$Map = { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -81,7 +81,7 @@ var $$Map = { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -99,7 +99,7 @@ var $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -113,7 +113,7 @@ var $$Map = { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -123,14 +123,14 @@ var $$Map = { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -175,7 +175,7 @@ var $$Map = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -194,7 +194,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -214,7 +214,7 @@ var $$Map = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -233,7 +233,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -253,7 +253,7 @@ var $$Map = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -269,7 +269,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -289,7 +289,7 @@ var $$Map = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -308,7 +308,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -328,7 +328,7 @@ var $$Map = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -342,7 +342,7 @@ var $$Map = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -356,7 +356,7 @@ var $$Map = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -370,14 +370,14 @@ var $$Map = { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -390,11 +390,11 @@ var $$Map = { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -407,14 +407,14 @@ var $$Map = { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -427,11 +427,11 @@ var $$Map = { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -442,7 +442,7 @@ var $$Map = { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -450,24 +450,24 @@ var $$Map = { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -494,7 +494,7 @@ var $$Map = { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -549,7 +549,7 @@ var $$Map = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -559,7 +559,7 @@ var $$Map = { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -574,7 +574,7 @@ var $$Map = { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -593,7 +593,7 @@ var $$Map = { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -604,7 +604,7 @@ var $$Map = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -620,7 +620,7 @@ var $$Map = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -634,25 +634,25 @@ var $$Map = { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -665,10 +665,10 @@ var $$Map = { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -682,7 +682,7 @@ var $$Map = { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -717,8 +717,8 @@ var $$Map = { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -730,7 +730,7 @@ var $$Map = { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -746,12 +746,12 @@ var $$Map = { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -778,7 +778,7 @@ var $$Map = { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -799,7 +799,7 @@ var $$Map = { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -830,7 +830,7 @@ var $$Map = { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -849,14 +849,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -878,14 +878,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -900,7 +900,7 @@ var $$Map = { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -910,7 +910,7 @@ var $$Map = { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -969,7 +969,7 @@ var $$Map = { var $$Set = { Make: (function (funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -977,9 +977,9 @@ var $$Set = { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -989,11 +989,11 @@ var $$Set = { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1006,7 +1006,7 @@ var $$Set = { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -1023,7 +1023,7 @@ var $$Set = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1036,7 +1036,7 @@ var $$Set = { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -1046,7 +1046,7 @@ var $$Set = { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -1085,25 +1085,25 @@ var $$Set = { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -1118,14 +1118,14 @@ var $$Set = { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -1135,11 +1135,11 @@ var $$Set = { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -1149,14 +1149,14 @@ var $$Set = { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -1166,11 +1166,11 @@ var $$Set = { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -1178,7 +1178,7 @@ var $$Set = { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -1186,32 +1186,32 @@ var $$Set = { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -1245,7 +1245,7 @@ var $$Set = { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -1254,7 +1254,7 @@ var $$Set = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -1266,7 +1266,7 @@ var $$Set = { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -1292,12 +1292,12 @@ var $$Set = { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -1316,10 +1316,10 @@ var $$Set = { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -1334,10 +1334,10 @@ var $$Set = { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -1355,7 +1355,7 @@ var $$Set = { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -1371,14 +1371,14 @@ var $$Set = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -1400,13 +1400,13 @@ var $$Set = { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -1447,7 +1447,7 @@ var $$Set = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -1460,7 +1460,7 @@ var $$Set = { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -1471,7 +1471,7 @@ var $$Set = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -1487,7 +1487,7 @@ var $$Set = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -1501,7 +1501,7 @@ var $$Set = { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -1521,7 +1521,7 @@ var $$Set = { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -1548,7 +1548,7 @@ var $$Set = { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1558,7 +1558,7 @@ var $$Set = { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -1575,7 +1575,7 @@ var $$Set = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1594,7 +1594,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -1610,7 +1610,7 @@ var $$Set = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1628,7 +1628,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -1644,7 +1644,7 @@ var $$Set = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1659,7 +1659,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -1675,7 +1675,7 @@ var $$Set = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1693,7 +1693,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -1709,7 +1709,7 @@ var $$Set = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1723,7 +1723,7 @@ var $$Set = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1743,7 +1743,7 @@ var $$Set = { } }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/es6/queue.js b/lib/es6/queue.js index 9f72c2f151..224dbf860a 100644 --- a/lib/es6/queue.js +++ b/lib/es6/queue.js @@ -25,7 +25,7 @@ function add(x, q) { next: "Nil" }; var last = q.last; - if (typeof last === "string") { + if (typeof last !== "object") { q.length = 1; q.first = cell; q.last = cell; @@ -38,7 +38,7 @@ function add(x, q) { function peek(q) { var match = q.first; - if (typeof match !== "string") { + if (typeof match === "object") { return match.content; } throw { @@ -49,7 +49,7 @@ function peek(q) { function take(q) { var match = q.first; - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: Empty, Error: new Error() @@ -57,7 +57,7 @@ function take(q) { } var content = match.content; var next = match.next; - if (typeof next === "string") { + if (typeof next !== "object") { clear(q); return content; } @@ -77,7 +77,7 @@ function copy(q) { while(true) { var cell = _cell; var prev = _prev; - if (typeof cell === "string") { + if (typeof cell !== "object") { q_res.last = prev; return q_res; } @@ -86,7 +86,7 @@ function copy(q) { content: cell.content, next: "Nil" }; - if (typeof prev === "string") { + if (typeof prev !== "object") { q_res.first = res; } else { prev.next = res; @@ -109,7 +109,7 @@ function iter(f, q) { var _cell = q.first; while(true) { var cell = _cell; - if (typeof cell === "string") { + if (typeof cell !== "object") { return ; } var next = cell.next; @@ -125,7 +125,7 @@ function fold(f, accu, q) { while(true) { var cell = _cell; var accu$1 = _accu; - if (typeof cell === "string") { + if (typeof cell !== "object") { return accu$1; } var next = cell.next; @@ -141,7 +141,7 @@ function transfer(q1, q2) { return ; } var last = q2.last; - if (typeof last === "string") { + if (typeof last !== "object") { q2.length = q1.length; q2.first = q1.first; q2.last = q1.last; diff --git a/lib/es6/set.js b/lib/es6/set.js index 3b8e7967ae..d71f9a449e 100644 --- a/lib/es6/set.js +++ b/lib/es6/set.js @@ -6,7 +6,7 @@ import * as Caml_option from "./caml_option.js"; function Make(funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -14,9 +14,9 @@ function Make(funarg) { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -26,11 +26,11 @@ function Make(funarg) { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -43,7 +43,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -60,7 +60,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -73,7 +73,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -83,7 +83,7 @@ function Make(funarg) { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -122,25 +122,25 @@ function Make(funarg) { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -155,14 +155,14 @@ function Make(funarg) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -172,11 +172,11 @@ function Make(funarg) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -186,14 +186,14 @@ function Make(funarg) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -203,11 +203,11 @@ function Make(funarg) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -215,7 +215,7 @@ function Make(funarg) { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -223,23 +223,23 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -273,7 +273,7 @@ function Make(funarg) { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -282,7 +282,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -294,7 +294,7 @@ function Make(funarg) { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -302,9 +302,9 @@ function Make(funarg) { var l = t.l; var c = Curry._2(funarg.compare, x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -326,12 +326,12 @@ function Make(funarg) { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -350,10 +350,10 @@ function Make(funarg) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -368,10 +368,10 @@ function Make(funarg) { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -389,7 +389,7 @@ function Make(funarg) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -407,14 +407,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -433,13 +433,13 @@ function Make(funarg) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -480,7 +480,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -493,7 +493,7 @@ function Make(funarg) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -504,7 +504,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -520,7 +520,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -534,7 +534,7 @@ function Make(funarg) { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -554,7 +554,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -581,7 +581,7 @@ function Make(funarg) { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -591,7 +591,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -608,7 +608,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -626,7 +626,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -639,7 +639,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -659,7 +659,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -669,7 +669,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -689,7 +689,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -702,7 +702,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -722,7 +722,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -732,7 +732,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -752,7 +752,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -765,7 +765,7 @@ function Make(funarg) { }; }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/es6/setLabels.js b/lib/es6/setLabels.js index 8c65084ca1..a01d500cd2 100644 --- a/lib/es6/setLabels.js +++ b/lib/es6/setLabels.js @@ -6,7 +6,7 @@ import * as Caml_option from "./caml_option.js"; function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -14,9 +14,9 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -26,11 +26,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -43,7 +43,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -60,7 +60,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -73,7 +73,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -83,7 +83,7 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -122,25 +122,25 @@ function Make(Ord) { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -155,14 +155,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -172,11 +172,11 @@ function Make(Ord) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -186,14 +186,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -203,11 +203,11 @@ function Make(Ord) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -215,7 +215,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -223,32 +223,32 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -282,7 +282,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -291,7 +291,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -303,7 +303,7 @@ function Make(Ord) { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -329,12 +329,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -353,10 +353,10 @@ function Make(Ord) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -371,10 +371,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -392,7 +392,7 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -408,14 +408,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -437,13 +437,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -484,7 +484,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -497,7 +497,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -508,7 +508,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -524,7 +524,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -538,7 +538,7 @@ function Make(Ord) { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -558,7 +558,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -585,7 +585,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -595,7 +595,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -612,7 +612,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -631,7 +631,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -647,7 +647,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -665,7 +665,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -681,7 +681,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -696,7 +696,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -712,7 +712,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -730,7 +730,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -746,7 +746,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -760,7 +760,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -780,7 +780,7 @@ function Make(Ord) { } }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/es6/stream.js b/lib/es6/stream.js index 74b8d71c83..cc68b8e2ac 100644 --- a/lib/es6/stream.js +++ b/lib/es6/stream.js @@ -31,7 +31,7 @@ function data(param) { function get_data(count, _d) { while(true) { var d = _d; - if (typeof d === "string") { + if (typeof d !== "object") { return d; } switch (d.TAG) { @@ -40,7 +40,7 @@ function get_data(count, _d) { case "Sapp" : var d2 = d._1; var match = get_data(count, d._0); - if (typeof match === "string") { + if (typeof match !== "object") { _d = d2; continue ; } @@ -102,7 +102,7 @@ function get_data(count, _d) { function peek_data(s) { while(true) { var f = s.data; - if (typeof f === "string") { + if (typeof f !== "object") { return ; } switch (f.TAG) { @@ -110,7 +110,7 @@ function peek_data(s) { return Caml_option.some(f._0); case "Sapp" : var d = get_data(s.count, s.data); - if (typeof d === "string") { + if (typeof d !== "object") { return ; } if (d.TAG === "Scons") { @@ -153,7 +153,7 @@ function peek(s) { function junk_data(s) { while(true) { var g = s.data; - if (typeof g !== "string") { + if (typeof g === "object") { switch (g.TAG) { case "Scons" : s.count = s.count + 1 | 0; @@ -428,7 +428,7 @@ function slazy(f) { } function dump_data(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { console.log("Sempty"); return ; } diff --git a/lib/js/caml_module.js b/lib/js/caml_module.js index 84effc7b1d..91585755a4 100644 --- a/lib/js/caml_module.js +++ b/lib/js/caml_module.js @@ -11,7 +11,7 @@ function init_mod(loc, shape) { }; }; var loop = function (shape, struct_, idx) { - if (typeof shape === "string") { + if (typeof shape !== "object") { switch (shape) { case "Function" : struct_[idx] = undef_module; @@ -56,7 +56,7 @@ function init_mod(loc, shape) { function update_mod(shape, o, n) { var aux = function (shape, o, n, parent, i) { - if (typeof shape === "string") { + if (typeof shape !== "object") { switch (shape) { case "Function" : parent[i] = n; @@ -79,7 +79,7 @@ function update_mod(shape, o, n) { return ; } }; - if (typeof shape === "string") { + if (typeof shape !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index 3c64e12718..fd8a848409 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -92,7 +92,7 @@ function reset(h) { } function copy_bucketlist(param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var key = param.key; @@ -102,7 +102,7 @@ function copy_bucketlist(param) { while(true) { var param = _param; var prec = _prec; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var key = param.key; @@ -113,7 +113,7 @@ function copy_bucketlist(param) { data: data, next: next }; - if (typeof prec === "string") { + if (typeof prec !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -166,7 +166,7 @@ function resize(indexfun, h) { var insert_bucket = function (_cell) { while(true) { var cell = _cell; - if (typeof cell === "string") { + if (typeof cell !== "object") { return ; } var key = cell.key; @@ -179,7 +179,7 @@ function resize(indexfun, h) { }); var nidx = Curry._2(indexfun, h, key); var tail = Caml_array.get(ndata_tail, nidx); - if (typeof tail === "string") { + if (typeof tail !== "object") { Caml_array.set(ndata, nidx, cell$1); } else { tail.next = cell$1; @@ -197,7 +197,7 @@ function resize(indexfun, h) { } for(var i$1 = 0; i$1 < nsize; ++i$1){ var tail = Caml_array.get(ndata_tail, i$1); - if (typeof tail !== "string") { + if (typeof tail === "object") { tail.next = "Empty"; } @@ -230,14 +230,14 @@ function remove(h, key) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Caml_obj.equal(k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -252,7 +252,7 @@ function remove(h, key) { function find(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -264,7 +264,7 @@ function find(h, key) { if (Caml_obj.equal(key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -276,7 +276,7 @@ function find(h, key) { if (Caml_obj.equal(key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -291,7 +291,7 @@ function find(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -311,7 +311,7 @@ function find(h, key) { function find_opt(h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -320,7 +320,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -329,7 +329,7 @@ function find_opt(h, key) { if (Caml_obj.equal(key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -341,7 +341,7 @@ function find_opt(h, key) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -360,7 +360,7 @@ function find_all(h, key) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -382,7 +382,7 @@ function find_all(h, key) { function replace_bucket(key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -420,7 +420,7 @@ function mem(h, key) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; @@ -437,7 +437,7 @@ function iter(f, h) { var do_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var key = param.key; @@ -476,8 +476,8 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { while(true) { var slot = _slot; var prec = _prec; - if (typeof slot === "string") { - if (typeof prec === "string") { + if (typeof slot !== "object") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, "Empty"); } else { prec.next = "Empty"; @@ -489,7 +489,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _slot) { var next = slot.next; var data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { - if (typeof prec === "string") { + if (typeof prec !== "object") { Caml_array.set(h.data, i, slot); } else { prec.next = slot; @@ -531,7 +531,7 @@ function fold(f, h, init) { while(true) { var accu = _accu; var b = _b; - if (typeof b === "string") { + if (typeof b !== "object") { return accu; } var key = b.key; @@ -570,7 +570,7 @@ function bucket_length(_accu, _param) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } var next = param.next; @@ -622,14 +622,14 @@ function MakeSeeded(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -643,7 +643,7 @@ function MakeSeeded(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -655,7 +655,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -667,7 +667,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -682,7 +682,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -701,7 +701,7 @@ function MakeSeeded(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -710,7 +710,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -719,7 +719,7 @@ function MakeSeeded(H) { if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -731,7 +731,7 @@ function MakeSeeded(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -749,7 +749,7 @@ function MakeSeeded(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -770,7 +770,7 @@ function MakeSeeded(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -806,7 +806,7 @@ function MakeSeeded(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; @@ -864,14 +864,14 @@ function Make(H) { while(true) { var c = _c; var prec = _prec; - if (typeof c === "string") { + if (typeof c !== "object") { return ; } var k = c.key; var next = c.next; if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; - if (typeof prec === "string") { + if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); } else { prec.next = next; @@ -885,7 +885,7 @@ function Make(H) { }; var find = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -897,7 +897,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return d1; } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -909,7 +909,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return d2; } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -924,7 +924,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -943,7 +943,7 @@ function Make(H) { }; var find_opt = function (h, key) { var match = Caml_array.get(h.data, key_index(h, key)); - if (typeof match === "string") { + if (typeof match !== "object") { return ; } var k1 = match.key; @@ -952,7 +952,7 @@ function Make(H) { if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } - if (typeof next1 === "string") { + if (typeof next1 !== "object") { return ; } var k2 = next1.key; @@ -961,7 +961,7 @@ function Make(H) { if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } - if (typeof next2 === "string") { + if (typeof next2 !== "object") { return ; } var k3 = next2.key; @@ -973,7 +973,7 @@ function Make(H) { var _param = next3; while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var k = param.key; @@ -991,7 +991,7 @@ function Make(H) { var find_in_bucket = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return /* [] */0; } var k = param.key; @@ -1012,7 +1012,7 @@ function Make(H) { var replace_bucket = function (key, data, _slot) { while(true) { var slot = _slot; - if (typeof slot === "string") { + if (typeof slot !== "object") { return true; } var k = slot.key; @@ -1048,7 +1048,7 @@ function Make(H) { var _param = Caml_array.get(h.data, key_index(h, key)); while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var k = param.key; diff --git a/lib/js/map.js b/lib/js/map.js index d8c4fa335c..8ae3986486 100644 --- a/lib/js/map.js +++ b/lib/js/map.js @@ -5,7 +5,7 @@ var Caml_option = require("./caml_option.js"); function Make(funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -33,11 +33,11 @@ function Make(funarg) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -51,7 +51,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -69,7 +69,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +83,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -93,14 +93,14 @@ function Make(funarg) { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -145,7 +145,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -162,7 +162,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -177,7 +177,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -201,7 +201,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -213,7 +213,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -237,7 +237,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -252,7 +252,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -276,7 +276,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -288,7 +288,7 @@ function Make(funarg) { var param$1 = _param$1; var d0 = _d0; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return [ v0, d0 @@ -312,7 +312,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -326,7 +326,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -340,14 +340,14 @@ function Make(funarg) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -360,11 +360,11 @@ function Make(funarg) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -377,14 +377,14 @@ function Make(funarg) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -397,11 +397,11 @@ function Make(funarg) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -412,7 +412,7 @@ function Make(funarg) { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -420,24 +420,24 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -464,7 +464,7 @@ function Make(funarg) { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -519,7 +519,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -529,7 +529,7 @@ function Make(funarg) { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -544,7 +544,7 @@ function Make(funarg) { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -563,7 +563,7 @@ function Make(funarg) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -574,7 +574,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -590,7 +590,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -604,25 +604,25 @@ function Make(funarg) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -635,10 +635,10 @@ function Make(funarg) { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -652,7 +652,7 @@ function Make(funarg) { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -687,8 +687,8 @@ function Make(funarg) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -700,7 +700,7 @@ function Make(funarg) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -716,12 +716,12 @@ function Make(funarg) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -748,7 +748,7 @@ function Make(funarg) { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -769,7 +769,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -800,7 +800,7 @@ function Make(funarg) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -819,14 +819,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -848,14 +848,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -870,7 +870,7 @@ function Make(funarg) { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -880,7 +880,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/lib/js/mapLabels.js b/lib/js/mapLabels.js index 77f0473a55..463c4e5ffd 100644 --- a/lib/js/mapLabels.js +++ b/lib/js/mapLabels.js @@ -5,7 +5,7 @@ var Caml_option = require("./caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -33,11 +33,11 @@ function Make(Ord) { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -51,7 +51,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -69,7 +69,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -83,7 +83,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -93,14 +93,14 @@ function Make(Ord) { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -145,7 +145,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -164,7 +164,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -184,7 +184,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -203,7 +203,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -223,7 +223,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -239,7 +239,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -259,7 +259,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -278,7 +278,7 @@ function Make(Ord) { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -298,7 +298,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -312,7 +312,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(Ord.compare, x, param.v); @@ -326,7 +326,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -340,14 +340,14 @@ function Make(Ord) { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -360,11 +360,11 @@ function Make(Ord) { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -377,14 +377,14 @@ function Make(Ord) { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -397,11 +397,11 @@ function Make(Ord) { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -412,7 +412,7 @@ function Make(Ord) { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -420,24 +420,24 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -464,7 +464,7 @@ function Make(Ord) { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -519,7 +519,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -529,7 +529,7 @@ function Make(Ord) { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -544,7 +544,7 @@ function Make(Ord) { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -563,7 +563,7 @@ function Make(Ord) { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -574,7 +574,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -590,7 +590,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -604,25 +604,25 @@ function Make(Ord) { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -635,10 +635,10 @@ function Make(Ord) { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -652,7 +652,7 @@ function Make(Ord) { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -687,8 +687,8 @@ function Make(Ord) { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -700,7 +700,7 @@ function Make(Ord) { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -716,12 +716,12 @@ function Make(Ord) { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -748,7 +748,7 @@ function Make(Ord) { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -769,7 +769,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -800,7 +800,7 @@ function Make(Ord) { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -819,14 +819,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -848,14 +848,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { @@ -870,7 +870,7 @@ function Make(Ord) { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -880,7 +880,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; diff --git a/lib/js/moreLabels.js b/lib/js/moreLabels.js index 038e6624af..7c79b5b7b9 100644 --- a/lib/js/moreLabels.js +++ b/lib/js/moreLabels.js @@ -35,7 +35,7 @@ var Hashtbl = { var $$Map = { Make: (function (funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -63,11 +63,11 @@ var $$Map = { }; var bal = function (l, x, d, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -81,7 +81,7 @@ var $$Map = { if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } throw { @@ -99,7 +99,7 @@ var $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.bal", @@ -113,7 +113,7 @@ var $$Map = { if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } throw { @@ -123,14 +123,14 @@ var $$Map = { }; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; } }; var add = function (x, data, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return /* Node */{ l: "Empty", v: x, @@ -175,7 +175,7 @@ var $$Map = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -194,7 +194,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -214,7 +214,7 @@ var $$Map = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -233,7 +233,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -253,7 +253,7 @@ var $$Map = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -269,7 +269,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -289,7 +289,7 @@ var $$Map = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -308,7 +308,7 @@ var $$Map = { var param = _param; var d0 = _d0; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return [ v0, d0 @@ -328,7 +328,7 @@ var $$Map = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -342,7 +342,7 @@ var $$Map = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var c = Curry._2(funarg.compare, x, param.v); @@ -356,7 +356,7 @@ var $$Map = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -370,14 +370,14 @@ var $$Map = { var min_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -390,11 +390,11 @@ var $$Map = { var min_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return [ param.v, param.d @@ -407,14 +407,14 @@ var $$Map = { var max_binding = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -427,11 +427,11 @@ var $$Map = { var max_binding_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return [ param.v, param.d @@ -442,7 +442,7 @@ var $$Map = { }; }; var remove_min_binding = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Map.remove_min_elt", @@ -450,24 +450,24 @@ var $$Map = { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; var remove = function (x, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -494,7 +494,7 @@ var $$Map = { } }; var update = function (x, f, m) { - if (typeof m === "string") { + if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { return /* Node */{ @@ -549,7 +549,7 @@ var $$Map = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -559,7 +559,7 @@ var $$Map = { }; }; var map = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var l$p = map(f, param.l); @@ -574,7 +574,7 @@ var $$Map = { }; }; var mapi = function (f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return "Empty"; } var v = param.v; @@ -593,7 +593,7 @@ var $$Map = { while(true) { var accu = _accu; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return accu; } _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); @@ -604,7 +604,7 @@ var $$Map = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._2(p, param.v, param.d)) { @@ -620,7 +620,7 @@ var $$Map = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._2(p, param.v, param.d)) { @@ -634,25 +634,25 @@ var $$Map = { }; }; var add_min_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; var add_max_binding = function (k, x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; var join = function (l, v, d, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_binding(v, d, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_binding(v, d, l); } var rh = r.h; @@ -665,10 +665,10 @@ var $$Map = { } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; } - if (typeof t2 === "string") { + if (typeof t2 !== "object") { return t1; } var match = min_binding(t2); @@ -682,7 +682,7 @@ var $$Map = { } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", undefined, @@ -717,8 +717,8 @@ var $$Map = { ]; }; var merge$1 = function (f, s1, s2) { - if (typeof s1 === "string") { - if (typeof s2 === "string") { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { return "Empty"; } @@ -730,7 +730,7 @@ var $$Map = { } } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -746,12 +746,12 @@ var $$Map = { return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; var union = function (f, s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var d1 = s1.d; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var d2 = s2.d; @@ -778,7 +778,7 @@ var $$Map = { } }; var filter = function (p, m) { - if (typeof m === "string") { + if (typeof m !== "object") { return "Empty"; } var r = m.r; @@ -799,7 +799,7 @@ var $$Map = { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -830,7 +830,7 @@ var $$Map = { while(true) { var e = _e; var m = _m; - if (typeof m === "string") { + if (typeof m !== "object") { return e; } _e = /* More */{ @@ -849,14 +849,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -878,14 +878,14 @@ var $$Map = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return true; } else { return false; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return false; } if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { @@ -900,7 +900,7 @@ var $$Map = { }; }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -910,7 +910,7 @@ var $$Map = { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -969,7 +969,7 @@ var $$Map = { var $$Set = { Make: (function (funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -977,9 +977,9 @@ var $$Set = { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -989,11 +989,11 @@ var $$Set = { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1006,7 +1006,7 @@ var $$Set = { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -1023,7 +1023,7 @@ var $$Set = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -1036,7 +1036,7 @@ var $$Set = { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -1046,7 +1046,7 @@ var $$Set = { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -1085,25 +1085,25 @@ var $$Set = { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -1118,14 +1118,14 @@ var $$Set = { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -1135,11 +1135,11 @@ var $$Set = { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -1149,14 +1149,14 @@ var $$Set = { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -1166,11 +1166,11 @@ var $$Set = { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -1178,7 +1178,7 @@ var $$Set = { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -1186,32 +1186,32 @@ var $$Set = { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -1245,7 +1245,7 @@ var $$Set = { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -1254,7 +1254,7 @@ var $$Set = { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -1266,7 +1266,7 @@ var $$Set = { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -1292,12 +1292,12 @@ var $$Set = { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -1316,10 +1316,10 @@ var $$Set = { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -1334,10 +1334,10 @@ var $$Set = { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -1355,7 +1355,7 @@ var $$Set = { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -1371,14 +1371,14 @@ var $$Set = { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -1400,13 +1400,13 @@ var $$Set = { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -1447,7 +1447,7 @@ var $$Set = { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -1460,7 +1460,7 @@ var $$Set = { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -1471,7 +1471,7 @@ var $$Set = { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -1487,7 +1487,7 @@ var $$Set = { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -1501,7 +1501,7 @@ var $$Set = { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -1521,7 +1521,7 @@ var $$Set = { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -1548,7 +1548,7 @@ var $$Set = { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -1558,7 +1558,7 @@ var $$Set = { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -1575,7 +1575,7 @@ var $$Set = { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1594,7 +1594,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -1610,7 +1610,7 @@ var $$Set = { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1628,7 +1628,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -1644,7 +1644,7 @@ var $$Set = { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1659,7 +1659,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -1675,7 +1675,7 @@ var $$Set = { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -1693,7 +1693,7 @@ var $$Set = { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -1709,7 +1709,7 @@ var $$Set = { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1723,7 +1723,7 @@ var $$Set = { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -1743,7 +1743,7 @@ var $$Set = { } }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/js/queue.js b/lib/js/queue.js index 8518ba0e0e..a33c520d58 100644 --- a/lib/js/queue.js +++ b/lib/js/queue.js @@ -25,7 +25,7 @@ function add(x, q) { next: "Nil" }; var last = q.last; - if (typeof last === "string") { + if (typeof last !== "object") { q.length = 1; q.first = cell; q.last = cell; @@ -38,7 +38,7 @@ function add(x, q) { function peek(q) { var match = q.first; - if (typeof match !== "string") { + if (typeof match === "object") { return match.content; } throw { @@ -49,7 +49,7 @@ function peek(q) { function take(q) { var match = q.first; - if (typeof match === "string") { + if (typeof match !== "object") { throw { RE_EXN_ID: Empty, Error: new Error() @@ -57,7 +57,7 @@ function take(q) { } var content = match.content; var next = match.next; - if (typeof next === "string") { + if (typeof next !== "object") { clear(q); return content; } @@ -77,7 +77,7 @@ function copy(q) { while(true) { var cell = _cell; var prev = _prev; - if (typeof cell === "string") { + if (typeof cell !== "object") { q_res.last = prev; return q_res; } @@ -86,7 +86,7 @@ function copy(q) { content: cell.content, next: "Nil" }; - if (typeof prev === "string") { + if (typeof prev !== "object") { q_res.first = res; } else { prev.next = res; @@ -109,7 +109,7 @@ function iter(f, q) { var _cell = q.first; while(true) { var cell = _cell; - if (typeof cell === "string") { + if (typeof cell !== "object") { return ; } var next = cell.next; @@ -125,7 +125,7 @@ function fold(f, accu, q) { while(true) { var cell = _cell; var accu$1 = _accu; - if (typeof cell === "string") { + if (typeof cell !== "object") { return accu$1; } var next = cell.next; @@ -141,7 +141,7 @@ function transfer(q1, q2) { return ; } var last = q2.last; - if (typeof last === "string") { + if (typeof last !== "object") { q2.length = q1.length; q2.first = q1.first; q2.last = q1.last; diff --git a/lib/js/set.js b/lib/js/set.js index 6c4e61d394..8f8b83f85e 100644 --- a/lib/js/set.js +++ b/lib/js/set.js @@ -6,7 +6,7 @@ var Caml_option = require("./caml_option.js"); function Make(funarg) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -14,9 +14,9 @@ function Make(funarg) { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -26,11 +26,11 @@ function Make(funarg) { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -43,7 +43,7 @@ function Make(funarg) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -60,7 +60,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -73,7 +73,7 @@ function Make(funarg) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -83,7 +83,7 @@ function Make(funarg) { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -122,25 +122,25 @@ function Make(funarg) { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -155,14 +155,14 @@ function Make(funarg) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -172,11 +172,11 @@ function Make(funarg) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -186,14 +186,14 @@ function Make(funarg) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -203,11 +203,11 @@ function Make(funarg) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -215,7 +215,7 @@ function Make(funarg) { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -223,23 +223,23 @@ function Make(funarg) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -273,7 +273,7 @@ function Make(funarg) { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -282,7 +282,7 @@ function Make(funarg) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(funarg.compare, x, param.v); @@ -294,7 +294,7 @@ function Make(funarg) { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -302,9 +302,9 @@ function Make(funarg) { var l = t.l; var c = Curry._2(funarg.compare, x, v); if (c === 0) { - if (typeof l === "string") { + if (typeof l !== "object") { return r; - } else if (typeof r === "string") { + } else if (typeof r !== "object") { return l; } else { return bal(l, min_elt(r), remove_min_elt(r)); @@ -326,12 +326,12 @@ function Make(funarg) { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -350,10 +350,10 @@ function Make(funarg) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -368,10 +368,10 @@ function Make(funarg) { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -389,7 +389,7 @@ function Make(funarg) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -407,14 +407,14 @@ function Make(funarg) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(funarg.compare, e1._0, e2._0); @@ -433,13 +433,13 @@ function Make(funarg) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -480,7 +480,7 @@ function Make(funarg) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -493,7 +493,7 @@ function Make(funarg) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -504,7 +504,7 @@ function Make(funarg) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -520,7 +520,7 @@ function Make(funarg) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -534,7 +534,7 @@ function Make(funarg) { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -554,7 +554,7 @@ function Make(funarg) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -581,7 +581,7 @@ function Make(funarg) { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -591,7 +591,7 @@ function Make(funarg) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -608,7 +608,7 @@ function Make(funarg) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -626,7 +626,7 @@ function Make(funarg) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -639,7 +639,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -659,7 +659,7 @@ function Make(funarg) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -669,7 +669,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -689,7 +689,7 @@ function Make(funarg) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -702,7 +702,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return v0; } var v$1 = param$1.v; @@ -722,7 +722,7 @@ function Make(funarg) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -732,7 +732,7 @@ function Make(funarg) { while(true) { var param$1 = _param$1; var v0 = _v0; - if (typeof param$1 === "string") { + if (typeof param$1 !== "object") { return Caml_option.some(v0); } var v$1 = param$1.v; @@ -752,7 +752,7 @@ function Make(funarg) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -765,7 +765,7 @@ function Make(funarg) { }; }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/js/setLabels.js b/lib/js/setLabels.js index a3addb80bf..c728ff6dbd 100644 --- a/lib/js/setLabels.js +++ b/lib/js/setLabels.js @@ -6,7 +6,7 @@ var Caml_option = require("./caml_option.js"); function Make(Ord) { var height = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return param.h; @@ -14,9 +14,9 @@ function Make(Ord) { }; var create = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; return /* Node */{ l: l, v: v, @@ -26,11 +26,11 @@ function Make(Ord) { }; var bal = function (l, v, r) { var hl; - hl = typeof l === "string" ? 0 : l.h; + hl = typeof l !== "object" ? 0 : l.h; var hr; - hr = typeof r === "string" ? 0 : r.h; + hr = typeof r !== "object" ? 0 : r.h; if (hl > (hr + 2 | 0)) { - if (typeof l === "string") { + if (typeof l !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -43,7 +43,7 @@ function Make(Ord) { if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } - if (typeof lr !== "string") { + if (typeof lr === "object") { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } throw { @@ -60,7 +60,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; } - if (typeof r === "string") { + if (typeof r !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.bal", @@ -73,7 +73,7 @@ function Make(Ord) { if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } - if (typeof rl !== "string") { + if (typeof rl === "object") { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } throw { @@ -83,7 +83,7 @@ function Make(Ord) { }; }; var add = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return /* Node */{ l: "Empty", v: x, @@ -122,25 +122,25 @@ function Make(Ord) { }; }; var add_min_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; var add_max_element = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; var join = function (l, v, r) { - if (typeof l === "string") { + if (typeof l !== "object") { return add_min_element(v, r); } var lh = l.h; - if (typeof r === "string") { + if (typeof r !== "object") { return add_max_element(v, l); } var rh = r.h; @@ -155,14 +155,14 @@ function Make(Ord) { var min_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.v; } _param = l; @@ -172,11 +172,11 @@ function Make(Ord) { var min_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return Caml_option.some(param.v); } _param = l; @@ -186,14 +186,14 @@ function Make(Ord) { var max_elt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() }; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return param.v; } _param = r; @@ -203,11 +203,11 @@ function Make(Ord) { var max_elt_opt = function (_param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var r = param.r; - if (typeof r === "string") { + if (typeof r !== "object") { return Caml_option.some(param.v); } _param = r; @@ -215,7 +215,7 @@ function Make(Ord) { }; }; var remove_min_elt = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Invalid_argument", _1: "Set.remove_min_elt", @@ -223,32 +223,32 @@ function Make(Ord) { }; } var l = param.l; - if (typeof l === "string") { + if (typeof l !== "object") { return param.r; } else { return bal(remove_min_elt(l), param.v, param.r); } }; var merge = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; var concat = function (t1, t2) { - if (typeof t1 === "string") { + if (typeof t1 !== "object") { return t2; - } else if (typeof t2 === "string") { + } else if (typeof t2 !== "object") { return t1; } else { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; var split = function (x, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", false, @@ -282,7 +282,7 @@ function Make(Ord) { ]; }; var is_empty = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return true; } else { return false; @@ -291,7 +291,7 @@ function Make(Ord) { var mem = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } var c = Curry._2(Ord.compare, x, param.v); @@ -303,7 +303,7 @@ function Make(Ord) { }; }; var remove = function (x, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -329,12 +329,12 @@ function Make(Ord) { } }; var union = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return s2; } var h1 = s1.h; var v1 = s1.v; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var h2 = s2.h; @@ -353,10 +353,10 @@ function Make(Ord) { return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; var inter = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return "Empty"; } var r1 = s1.r; @@ -371,10 +371,10 @@ function Make(Ord) { } }; var diff = function (s1, s2) { - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return "Empty"; } - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return s1; } var r1 = s1.r; @@ -392,7 +392,7 @@ function Make(Ord) { while(true) { var e = _e; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return e; } _e = /* More */{ @@ -408,14 +408,14 @@ function Make(Ord) { while(true) { var e2 = _e2; var e1 = _e1; - if (typeof e1 === "string") { - if (typeof e2 === "string") { + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { return 0; } else { return -1; } } - if (typeof e2 === "string") { + if (typeof e2 !== "object") { return 1; } var c = Curry._2(Ord.compare, e1._0, e2._0); @@ -437,13 +437,13 @@ function Make(Ord) { while(true) { var s2 = _s2; var s1 = _s1; - if (typeof s1 === "string") { + if (typeof s1 !== "object") { return true; } var r1 = s1.r; var v1 = s1.v; var l1 = s1.l; - if (typeof s2 === "string") { + if (typeof s2 !== "object") { return false; } var r2 = s2.r; @@ -484,7 +484,7 @@ function Make(Ord) { var iter = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } iter(f, param.l); @@ -497,7 +497,7 @@ function Make(Ord) { while(true) { var accu = _accu; var s = _s; - if (typeof s === "string") { + if (typeof s !== "object") { return accu; } _accu = Curry._2(f, s.v, fold(f, s.l, accu)); @@ -508,7 +508,7 @@ function Make(Ord) { var for_all = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return true; } if (!Curry._1(p, param.v)) { @@ -524,7 +524,7 @@ function Make(Ord) { var exists = function (p, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return false; } if (Curry._1(p, param.v)) { @@ -538,7 +538,7 @@ function Make(Ord) { }; }; var filter = function (p, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; @@ -558,7 +558,7 @@ function Make(Ord) { } }; var partition = function (p, param) { - if (typeof param === "string") { + if (typeof param !== "object") { return [ "Empty", "Empty" @@ -585,7 +585,7 @@ function Make(Ord) { } }; var cardinal = function (param) { - if (typeof param === "string") { + if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; @@ -595,7 +595,7 @@ function Make(Ord) { while(true) { var param = _param; var accu = _accu; - if (typeof param === "string") { + if (typeof param !== "object") { return accu; } _param = param.l; @@ -612,7 +612,7 @@ function Make(Ord) { var find = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -631,7 +631,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -647,7 +647,7 @@ function Make(Ord) { var find_first = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -665,7 +665,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -681,7 +681,7 @@ function Make(Ord) { var find_first_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -696,7 +696,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return v0; } var v = param.v; @@ -712,7 +712,7 @@ function Make(Ord) { var find_last = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { throw { RE_EXN_ID: "Not_found", Error: new Error() @@ -730,7 +730,7 @@ function Make(Ord) { while(true) { var param = _param; var v0 = _v0; - if (typeof param === "string") { + if (typeof param !== "object") { return Caml_option.some(v0); } var v = param.v; @@ -746,7 +746,7 @@ function Make(Ord) { var find_last_opt = function (f, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -760,7 +760,7 @@ function Make(Ord) { var find_opt = function (x, _param) { while(true) { var param = _param; - if (typeof param === "string") { + if (typeof param !== "object") { return ; } var v = param.v; @@ -780,7 +780,7 @@ function Make(Ord) { } }; var map = function (f, t) { - if (typeof t === "string") { + if (typeof t !== "object") { return "Empty"; } var r = t.r; diff --git a/lib/js/stream.js b/lib/js/stream.js index 421e3288f2..3c564319c9 100644 --- a/lib/js/stream.js +++ b/lib/js/stream.js @@ -31,7 +31,7 @@ function data(param) { function get_data(count, _d) { while(true) { var d = _d; - if (typeof d === "string") { + if (typeof d !== "object") { return d; } switch (d.TAG) { @@ -40,7 +40,7 @@ function get_data(count, _d) { case "Sapp" : var d2 = d._1; var match = get_data(count, d._0); - if (typeof match === "string") { + if (typeof match !== "object") { _d = d2; continue ; } @@ -102,7 +102,7 @@ function get_data(count, _d) { function peek_data(s) { while(true) { var f = s.data; - if (typeof f === "string") { + if (typeof f !== "object") { return ; } switch (f.TAG) { @@ -110,7 +110,7 @@ function peek_data(s) { return Caml_option.some(f._0); case "Sapp" : var d = get_data(s.count, s.data); - if (typeof d === "string") { + if (typeof d !== "object") { return ; } if (d.TAG === "Scons") { @@ -153,7 +153,7 @@ function peek(s) { function junk_data(s) { while(true) { var g = s.data; - if (typeof g !== "string") { + if (typeof g === "object") { switch (g.TAG) { case "Scons" : s.count = s.count + 1 | 0; @@ -428,7 +428,7 @@ function slazy(f) { } function dump_data(f, param) { - if (typeof param === "string") { + if (typeof param !== "object") { console.log("Sempty"); return ; } From 4d925d37d971ba3be2ae661c7f722124efa9641c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 22 Mar 2023 16:52:04 +0100 Subject: [PATCH 03/13] Do not special case variants with only 1 case with payload. Also the comment is not emitted anymore, since there's always a tag. Not special casing means that the representation is uniform, and does not change when the type is extended. This is important with zero cost ffi, where the runtime representation is exposed to the user, to reduce possible surprises. --- jscomp/runtime/release.ninja | 6 +- jscomp/test/bal_set_mini.js | 9 +- jscomp/test/bdd.js | 3 +- jscomp/test/defunctor_make_test.js | 12 +- jscomp/test/demo_int_map.js | 12 +- jscomp/test/demo_page.js | 3 +- jscomp/test/flexible_array_test.js | 27 ++-- jscomp/test/flow_parser_reg_test.js | 45 ++++--- jscomp/test/gpr_5280_optimize_test.js | 3 +- jscomp/test/inline_map2_test.js | 72 ++++++---- jscomp/test/inline_map_demo.js | 12 +- jscomp/test/inline_map_test.js | 12 +- jscomp/test/inline_record_test.js | 9 +- jscomp/test/int_map.js | 30 +++-- jscomp/test/large_record_duplication_test.js | 3 +- jscomp/test/map_find_test.js | 24 ++-- jscomp/test/map_test.js | 27 ++-- jscomp/test/mario_game.js | 3 +- jscomp/test/mutual_non_recursive_type.js | 3 +- jscomp/test/ocaml_re_test.js | 27 ++-- jscomp/test/offset.js | 39 ++++-- jscomp/test/pq_test.js | 15 ++- jscomp/test/rbset.js | 132 ++++++++++++------- jscomp/test/rec_module_test.js | 39 ++++-- jscomp/test/recursive_records_test.js | 3 +- jscomp/test/set_gen.js | 48 ++++--- jscomp/test/string_set.js | 9 +- jscomp/test/test_demo.js | 6 +- jscomp/test/test_fib.js | 6 +- jscomp/test/test_for_map.js | 30 +++-- jscomp/test/test_int_map_find.js | 12 +- jscomp/test/test_set.js | 39 ++++-- jscomp/test/test_string_map.js | 12 +- jscomp/test/ticker.js | 39 ++++-- jscomp/test/topsort_test.js | 39 ++++-- lib/es6/hashtbl.js | 27 ++-- lib/es6/map.js | 30 +++-- lib/es6/mapLabels.js | 30 +++-- lib/es6/moreLabels.js | 69 ++++++---- lib/es6/queue.js | 6 +- lib/es6/set.js | 39 ++++-- lib/es6/setLabels.js | 39 ++++-- lib/js/hashtbl.js | 27 ++-- lib/js/map.js | 30 +++-- lib/js/mapLabels.js | 30 +++-- lib/js/moreLabels.js | 69 ++++++---- lib/js/queue.js | 6 +- lib/js/set.js | 39 ++++-- lib/js/setLabels.js | 39 ++++-- 49 files changed, 859 insertions(+), 431 deletions(-) diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index 8798a72d19..24665ce5e3 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -21,7 +21,7 @@ o runtime/caml_bytes.cmj : cc_cmi runtime/caml_bytes.ml | runtime/caml_bytes.cmi o runtime/caml_bytes.cmi : cc runtime/caml_bytes.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float.cmj : cc_cmi runtime/caml_float.ml | runtime/caml_float.cmi runtime/caml_float_extern.cmj o runtime/caml_float.cmi : cc runtime/caml_float.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml.cmj runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj +o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj o runtime/caml_format.cmi : cc runtime/caml_format.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_hash.cmj : cc_cmi runtime/caml_hash.ml | runtime/caml_hash.cmi runtime/caml_hash_primitive.cmj runtime/caml_nativeint_extern.cmj runtime/js.cmj o runtime/caml_hash.cmi : cc runtime/caml_hash.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj @@ -37,7 +37,7 @@ o runtime/caml_md5.cmj : cc_cmi runtime/caml_md5.ml | runtime/caml_array_extern. o runtime/caml_md5.cmi : cc runtime/caml_md5.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_module.cmj : cc_cmi runtime/caml_module.ml | runtime/caml_array_extern.cmj runtime/caml_module.cmi runtime/caml_obj.cmj o runtime/caml_module.cmi : cc runtime/caml_module.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.ml | runtime/caml.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj +o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.ml | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj o runtime/caml_obj.cmi : cc runtime/caml_obj.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_option.cmj : cc_cmi runtime/caml_option.ml | runtime/caml_option.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj o runtime/caml_option.cmi : cc runtime/caml_option.mli | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj @@ -54,7 +54,7 @@ o runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj : cc runtime/caml_exce o runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj : cc runtime/caml_int64_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/caml_option.cmj runtime/js.cmi runtime/js.cmj +o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/js.cmi runtime/js.cmj o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runtime/caml_nativeint_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj diff --git a/jscomp/test/bal_set_mini.js b/jscomp/test/bal_set_mini.js index 1ed48609a3..c54c314a8f 100644 --- a/jscomp/test/bal_set_mini.js +++ b/jscomp/test/bal_set_mini.js @@ -12,7 +12,8 @@ function height(param) { function create(l, v, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -39,7 +40,8 @@ function bal(l, v, r) { } } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -73,7 +75,8 @@ function compare_int(x, y) { function add(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: "Empty", diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index 666336ecf3..c82e6baef6 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -170,7 +170,8 @@ function mkNode(low, v, high) { } } else { var n_2 = (nodeC.contents = nodeC.contents + 1 | 0, nodeC.contents); - var n$1 = /* Node */{ + var n$1 = { + TAG: "Node", _0: low, _1: v, _2: n_2, diff --git a/jscomp/test/defunctor_make_test.js b/jscomp/test/defunctor_make_test.js index bf3aa8c376..12d0b76fc6 100644 --- a/jscomp/test/defunctor_make_test.js +++ b/jscomp/test/defunctor_make_test.js @@ -26,7 +26,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -65,7 +66,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -99,7 +101,8 @@ function bal(l, x, d, r) { function add(x, data, compare, param) { if (typeof param !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -113,7 +116,8 @@ function add(x, data, compare, param) { var l = param._0; var c = compare(x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, diff --git a/jscomp/test/demo_int_map.js b/jscomp/test/demo_int_map.js index 1a2107a405..9480d86069 100644 --- a/jscomp/test/demo_int_map.js +++ b/jscomp/test/demo_int_map.js @@ -12,7 +12,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -51,7 +52,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -85,7 +87,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -102,7 +105,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 56b50b2693..d100c75bb8 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -24,7 +24,8 @@ function map(f, param) { if (typeof param !== "object") { return "Nil"; } else { - return /* Cons */{ + return { + TAG: "Cons", _0: Curry._1(f, param._0), _1: map(f, param._1) }; diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index 30d40d89fc..c8e968b4e5 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -32,7 +32,8 @@ function sub(_tr, _k) { function update(tr, k, w) { if (typeof tr !== "object") { if (k === 1) { - return /* Br */{ + return { + TAG: "Br", _0: w, _1: "Lf", _2: "Lf" @@ -46,7 +47,8 @@ function update(tr, k, w) { var r = tr._2; var l = tr._1; if (k === 1) { - return /* Br */{ + return { + TAG: "Br", _0: w, _1: l, _2: r @@ -54,13 +56,15 @@ function update(tr, k, w) { } var v = tr._0; if (k % 2 === 0) { - return /* Br */{ + return { + TAG: "Br", _0: v, _1: update(l, k / 2 | 0, w), _2: r }; } else { - return /* Br */{ + return { + TAG: "Br", _0: v, _1: l, _2: update(r, k / 2 | 0, w) @@ -82,13 +86,15 @@ function $$delete(tr, n) { var l = tr._1; var v = tr._0; if (n % 2 === 0) { - return /* Br */{ + return { + TAG: "Br", _0: v, _1: $$delete(l, n / 2 | 0), _2: r }; } else { - return /* Br */{ + return { + TAG: "Br", _0: v, _1: l, _2: $$delete(r, n / 2 | 0) @@ -98,13 +104,15 @@ function $$delete(tr, n) { function loext(tr, w) { if (typeof tr !== "object") { - return /* Br */{ + return { + TAG: "Br", _0: w, _1: "Lf", _2: "Lf" }; } else { - return /* Br */{ + return { + TAG: "Br", _0: w, _1: loext(tr._2, tr._0), _2: tr._1 @@ -121,7 +129,8 @@ function lorem(tr) { } var l = tr._1; if (typeof l === "object") { - return /* Br */{ + return { + TAG: "Br", _0: l._0, _1: tr._2, _2: lorem(l) diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index fd2223b806..0dbdc1cd36 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -5283,7 +5283,8 @@ function create(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -5320,7 +5321,8 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -5352,7 +5354,8 @@ function bal(l, v, r) { function add(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -6131,7 +6134,8 @@ function to_parse(env, parse) { try { var result = Curry._1(parse, env); reset_token_sink(true, env, saved_state.token_buffer); - return /* ParsedSuccessfully */{ + return { + TAG: "ParsedSuccessfully", _0: result }; } @@ -6183,7 +6187,8 @@ function create$2(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -6220,7 +6225,8 @@ function bal$1(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -6252,7 +6258,8 @@ function bal$1(l, v, r) { function add$1(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -6308,7 +6315,8 @@ function height$2(param) { function create$3(l, x, d, r) { var hl = height$2(l); var hr = height$2(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -6347,7 +6355,8 @@ function bal$2(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -6381,7 +6390,8 @@ function bal$2(l, x, d, r) { function add$2(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -6398,7 +6408,8 @@ function add$2(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -6463,7 +6474,8 @@ function create$4(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -6500,7 +6512,8 @@ function bal$3(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -6532,7 +6545,8 @@ function bal$3(l, v, r) { function add$3(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -15060,7 +15074,8 @@ function predicate(env) { var loc = btwn(checks_loc, rparen_loc); return [ loc, - /* Declared */{ + { + TAG: "Declared", _0: exp } ]; diff --git a/jscomp/test/gpr_5280_optimize_test.js b/jscomp/test/gpr_5280_optimize_test.js index fcb9872410..f986715f6a 100644 --- a/jscomp/test/gpr_5280_optimize_test.js +++ b/jscomp/test/gpr_5280_optimize_test.js @@ -1,7 +1,8 @@ 'use strict'; -var a = /* Color */{ +var a = { + TAG: "Color", _0: "#ffff" }; diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index 8796f62080..70085dca5e 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -17,7 +17,8 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -26,7 +27,8 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: d, @@ -64,7 +66,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -104,7 +107,8 @@ function Make(Ord) { }; var add = function (x, data, param) { if (typeof param !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -118,7 +122,8 @@ function Make(Ord) { var l = param._0; var c = Curry._2(Ord.compare, x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, @@ -260,7 +265,8 @@ function Make(Ord) { var l$p = map(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: param._1, _2: d$p, @@ -276,7 +282,8 @@ function Make(Ord) { var l$p = mapi(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: v, _2: d$p, @@ -490,7 +497,8 @@ function Make(Ord) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m._1, _1: m._2, _2: m._3, @@ -634,7 +642,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -644,7 +653,8 @@ function create(l, x, d, r) { } function singleton(x, d) { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: d, @@ -683,7 +693,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -725,7 +736,8 @@ function is_empty(param) { function add(x, data, param) { if (typeof param !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -739,7 +751,8 @@ function add(x, data, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, @@ -889,7 +902,8 @@ function map(f, param) { var l$p = map(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: param._1, _2: d$p, @@ -906,7 +920,8 @@ function mapi(f, param) { var l$p = mapi(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: v, _2: d$p, @@ -1133,7 +1148,8 @@ function cons_enum(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m._1, _1: m._2, _2: m._3, @@ -1310,7 +1326,8 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -1320,7 +1337,8 @@ function create$1(l, x, d, r) { } function singleton$1(x, d) { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: d, @@ -1359,7 +1377,8 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -1401,7 +1420,8 @@ function is_empty$1(param) { function add$1(x, data, param) { if (typeof param !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -1415,7 +1435,8 @@ function add$1(x, data, param) { var l = param._0; var c = Caml.string_compare(x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, @@ -1565,7 +1586,8 @@ function map$1(f, param) { var l$p = map$1(f, param._0); var d$p = Curry._1(f, param._2); var r$p = map$1(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: param._1, _2: d$p, @@ -1582,7 +1604,8 @@ function mapi$1(f, param) { var l$p = mapi$1(f, param._0); var d$p = Curry._2(f, v, param._2); var r$p = mapi$1(f, param._3); - return /* Node */{ + return { + TAG: "Node", _0: l$p, _1: v, _2: d$p, @@ -1809,7 +1832,8 @@ function cons_enum$1(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m._1, _1: m._2, _2: m._3, diff --git a/jscomp/test/inline_map_demo.js b/jscomp/test/inline_map_demo.js index a00cec9079..e731598bc5 100644 --- a/jscomp/test/inline_map_demo.js +++ b/jscomp/test/inline_map_demo.js @@ -15,7 +15,8 @@ function height(x) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -62,7 +63,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -104,7 +106,8 @@ function bal(l, x, d, r) { function add(x, data, tree) { if (typeof tree !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -118,7 +121,8 @@ function add(x, data, tree) { var l = tree._0; var c = Caml.int_compare(x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, diff --git a/jscomp/test/inline_map_test.js b/jscomp/test/inline_map_test.js index 2e50ecc5fb..2393bc1951 100644 --- a/jscomp/test/inline_map_test.js +++ b/jscomp/test/inline_map_test.js @@ -15,7 +15,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -54,7 +55,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: d, @@ -88,7 +90,8 @@ function bal(l, x, d, r) { function add(x, data, param) { if (typeof param !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: data, @@ -102,7 +105,8 @@ function add(x, data, param) { var l = param._0; var c = Caml.int_compare(x, v); if (c === 0) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: x, _2: data, diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 50de18de3f..6e2fb6a68c 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -184,7 +184,8 @@ function ff1(x) { if (typeof x !== "object") { return "A1"; } else { - return /* A0 */{ + return { + TAG: "A0", lbl: x.lbl + 1 | 0, more: x.more }; @@ -193,12 +194,14 @@ function ff1(x) { Mt.from_pair_suites("Inline_record_test", suites.contents); -var v2 = /* A0 */{ +var v2 = { + TAG: "A0", lbl: 3, more: /* [] */0 }; -var vvv = /* A0 */{ +var vvv = { + TAG: "A0", lbl: 3, more: /* [] */0 }; diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index 6cda098613..b563f70641 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -15,7 +15,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -25,7 +26,8 @@ function create(l, x, d, r) { } function singleton(x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -64,7 +66,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -106,7 +109,8 @@ function is_empty(param) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -123,7 +127,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -487,7 +492,8 @@ function update(x, f, m) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -512,7 +518,8 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -557,7 +564,8 @@ function map(f, param) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -574,7 +582,8 @@ function mapi(f, param) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -840,7 +849,8 @@ function cons_enum(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/jscomp/test/large_record_duplication_test.js b/jscomp/test/large_record_duplication_test.js index d6766ec4c8..66e5cbe7e3 100644 --- a/jscomp/test/large_record_duplication_test.js +++ b/jscomp/test/large_record_duplication_test.js @@ -56,7 +56,8 @@ eq("File \"large_record_duplication_test.ml\", line 74, characters 6-13", Caml_o y: "" }), false); -var v1 = /* A0 */{ +var v1 = { + TAG: "A0", x0: 9, x1: 9, x2: 9, diff --git a/jscomp/test/map_find_test.js b/jscomp/test/map_find_test.js index b26f9efda4..eb1e1b756b 100644 --- a/jscomp/test/map_find_test.js +++ b/jscomp/test/map_find_test.js @@ -15,7 +15,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -54,7 +55,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -88,7 +90,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -105,7 +108,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -187,7 +191,8 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -226,7 +231,8 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -260,7 +266,8 @@ function bal$1(l, x, d, r) { function add$1(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -277,7 +284,8 @@ function add$1(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index 90b9610244..7e9fd04fe8 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -16,7 +16,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -55,7 +56,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -89,7 +91,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -106,7 +109,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -138,7 +142,8 @@ function cons_enum(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, @@ -226,7 +231,8 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -265,7 +271,8 @@ function bal$1(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -299,7 +306,8 @@ function bal$1(l, x, d, r) { function add$1(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -316,7 +324,8 @@ function add$1(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 8c431cc0d3..6fb0522e76 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -2538,7 +2538,8 @@ function choose_sblock_typ(typ) { case 2 : return "Cloud"; case 3 : - return /* QBlock */{ + return { + TAG: "QBlock", _0: "Mushroom" }; case 4 : diff --git a/jscomp/test/mutual_non_recursive_type.js b/jscomp/test/mutual_non_recursive_type.js index f399ffb306..3c797680c7 100644 --- a/jscomp/test/mutual_non_recursive_type.js +++ b/jscomp/test/mutual_non_recursive_type.js @@ -9,7 +9,8 @@ var U = { f: f }; -var v = /* H */{ +var v = { + TAG: "H", _0: "OT" }; diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 77502cdf8f..beeba17e47 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -303,7 +303,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -342,7 +343,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -376,7 +378,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -393,7 +396,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -497,7 +501,8 @@ function create$1(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -534,7 +539,8 @@ function bal$1(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -566,7 +572,8 @@ function bal$1(l, v, r) { function add$1(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -1432,7 +1439,8 @@ function status(s) { break; case "TMatch" : var m$1 = m._0; - st$1 = /* Match */{ + st$1 = { + TAG: "Match", _0: flatten_match(m$1.marks), _1: m$1.pmarks }; @@ -3248,7 +3256,8 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { return "Running"; } } else { - return /* Match */{ + return { + TAG: "Match", _0: { s: s, marks: res._0, diff --git a/jscomp/test/offset.js b/jscomp/test/offset.js index 20aa7f4842..b3a7884756 100644 --- a/jscomp/test/offset.js +++ b/jscomp/test/offset.js @@ -19,7 +19,8 @@ function create(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -56,7 +57,8 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -88,7 +90,8 @@ function bal(l, v, r) { function add(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -119,7 +122,8 @@ function add(x, t) { } function singleton(x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -414,7 +418,8 @@ function cons_enum(_s, _e) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -479,7 +484,8 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -490,7 +496,8 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -858,7 +865,8 @@ function of_list(l) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -873,8 +881,10 @@ function of_list(l) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -897,15 +907,18 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/jscomp/test/pq_test.js b/jscomp/test/pq_test.js index b01d3d8206..06c96ac06a 100644 --- a/jscomp/test/pq_test.js +++ b/jscomp/test/pq_test.js @@ -4,7 +4,8 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); function insert(queue, prio, elt) { if (typeof queue !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: prio, _1: elt, _2: "Empty", @@ -16,14 +17,16 @@ function insert(queue, prio, elt) { var e = queue._1; var p = queue._0; if (prio <= p) { - return /* Node */{ + return { + TAG: "Node", _0: prio, _1: elt, _2: insert(right, p, e), _3: left }; } else { - return /* Node */{ + return { + TAG: "Node", _0: p, _1: e, _2: insert(right, prio, elt), @@ -53,14 +56,16 @@ function remove_top(param) { var rprio = right._0; var lprio = left._0; if (lprio <= rprio) { - return /* Node */{ + return { + TAG: "Node", _0: lprio, _1: left._1, _2: remove_top(left), _3: right }; } else { - return /* Node */{ + return { + TAG: "Node", _0: rprio, _1: right._1, _2: left, diff --git a/jscomp/test/rbset.js b/jscomp/test/rbset.js index ea3b42383c..fa7fe05339 100644 --- a/jscomp/test/rbset.js +++ b/jscomp/test/rbset.js @@ -9,7 +9,8 @@ function blackify(s) { ]; } else { return [ - /* Node */{ + { + TAG: "Node", _0: "Black", _1: s._1, _2: s._2, @@ -92,23 +93,27 @@ function balance_left(l, x, r) { } switch (exit) { case 1 : - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: l, _2: x, _3: r }; case 2 : - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: a, _2: x$1, _3: b }, _2: y, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: c, _2: z, @@ -164,23 +169,27 @@ function balance_right(l, x, r) { } switch (exit) { case 1 : - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: l, _2: x, _3: r }; case 2 : - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: a, _2: x$1, _3: b }, _2: y, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: c, _2: z, @@ -192,7 +201,8 @@ function balance_right(l, x, r) { } function singleton(x) { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: "Empty", _2: x, @@ -206,7 +216,8 @@ function unbalanced_left(param) { var match = param._1; if (typeof match === "object" && !match._0) { return [ - balance_left(/* Node */{ + balance_left({ + TAG: "Node", _0: "Red", _1: match._1, _2: match._2, @@ -221,7 +232,8 @@ function unbalanced_left(param) { if (typeof match$1 === "object") { if (!match$1._0) { return [ - balance_left(/* Node */{ + balance_left({ + TAG: "Node", _0: "Red", _1: match$1._1, _2: match$1._2, @@ -233,11 +245,13 @@ function unbalanced_left(param) { var match$2 = match$1._3; if (typeof match$2 === "object" && !match$2._0) { return [ - /* Node */{ + { + TAG: "Node", _0: "Black", _1: match$1._1, _2: match$1._2, - _3: balance_left(/* Node */{ + _3: balance_left({ + TAG: "Node", _0: "Red", _1: match$2._1, _2: match$2._2, @@ -269,7 +283,8 @@ function unbalanced_right(param) { var match = param._3; if (typeof match === "object" && !match._0) { return [ - balance_right(param._1, param._2, /* Node */{ + balance_right(param._1, param._2, { + TAG: "Node", _0: "Red", _1: match._1, _2: match._2, @@ -286,7 +301,8 @@ function unbalanced_right(param) { if (typeof match$1 === "object") { if (!match$1._0) { return [ - balance_right(a, x, /* Node */{ + balance_right(a, x, { + TAG: "Node", _0: "Red", _1: match$1._1, _2: match$1._2, @@ -298,9 +314,11 @@ function unbalanced_right(param) { var match$2 = match$1._1; if (typeof match$2 === "object" && !match$2._0) { return [ - /* Node */{ + { + TAG: "Node", _0: "Black", - _1: balance_right(a, x, /* Node */{ + _1: balance_right(a, x, { + TAG: "Node", _0: "Red", _1: match$2._1, _2: match$2._2, @@ -330,7 +348,8 @@ function unbalanced_right(param) { function lbalance(x1, x2, x3) { if (typeof x1 !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: x1, _2: x2, @@ -338,7 +357,8 @@ function lbalance(x1, x2, x3) { }; } if (!x1._0) { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: x1, _2: x2, @@ -348,16 +368,19 @@ function lbalance(x1, x2, x3) { var r = x1._3; var l = x1._1; if (typeof l === "object" && l._0) { - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: l._1, _2: l._2, _3: l._3 }, _2: x1._2, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: r, _2: x2, @@ -366,7 +389,8 @@ function lbalance(x1, x2, x3) { }; } if (typeof r !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: x1, _2: x2, @@ -374,7 +398,8 @@ function lbalance(x1, x2, x3) { }; } if (!r._0) { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: x1, _2: x2, @@ -382,16 +407,19 @@ function lbalance(x1, x2, x3) { }; } var y = r._2; - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: l, _2: y, _3: r._1 }, _2: y, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: r._3, _2: x2, @@ -408,16 +436,19 @@ function rbalance(x1, x2, x3) { exit = 2; } else { if (b._0) { - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: x1, _2: x2, _3: b._1 }, _2: b._2, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: b._3, _2: x3._2, @@ -430,16 +461,19 @@ function rbalance(x1, x2, x3) { if (exit === 2) { var match = x3._3; if (typeof match === "object" && match._0) { - return /* Node */{ + return { + TAG: "Node", _0: "Red", - _1: /* Node */{ + _1: { + TAG: "Node", _0: "Black", _1: x1, _2: x2, _3: b }, _2: x3._2, - _3: /* Node */{ + _3: { + TAG: "Node", _0: "Black", _1: match._1, _2: match._2, @@ -451,7 +485,8 @@ function rbalance(x1, x2, x3) { } } - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: x1, _2: x2, @@ -461,7 +496,8 @@ function rbalance(x1, x2, x3) { function ins(x, s) { if (typeof s !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Red", _1: "Empty", _2: x, @@ -476,14 +512,16 @@ function ins(x, s) { var b = s._3; var a = s._1; if (x < y) { - return /* Node */{ + return { + TAG: "Node", _0: "Red", _1: ins(x, a), _2: y, _3: b }; } else { - return /* Node */{ + return { + TAG: "Node", _0: "Red", _1: a, _2: y, @@ -509,7 +547,8 @@ function add(x, s) { if (typeof s$1 !== "object" || !s$1._0) { return s$1; } else { - return /* Node */{ + return { + TAG: "Node", _0: "Black", _1: s$1._1, _2: s$1._2, @@ -555,7 +594,8 @@ function remove_min(param) { } if (match._0) { return [ - /* Node */{ + { + TAG: "Node", _0: "Black", _1: match._1, _2: match._2, @@ -582,7 +622,8 @@ function remove_min(param) { var s_1 = match$1[0]; var s_2 = param._2; var s_3 = param._3; - var s = /* Node */{ + var s = { + TAG: "Node", _0: c, _1: s_1, _2: s_2, @@ -628,7 +669,8 @@ function remove_aux(x, n) { var match = remove_min(r); var n_2 = match[1]; var n_3 = match[0]; - var n$1 = /* Node */{ + var n$1 = { + TAG: "Node", _0: c, _1: l, _2: n_2, @@ -646,7 +688,8 @@ function remove_aux(x, n) { if (x < y) { var match$1 = remove_aux(x, l); var n_1 = match$1[0]; - var n$2 = /* Node */{ + var n$2 = { + TAG: "Node", _0: c, _1: n_1, _2: y, @@ -663,7 +706,8 @@ function remove_aux(x, n) { } var match$2 = remove_aux(x, r); var n_3$1 = match$2[0]; - var n$3 = /* Node */{ + var n$3 = { + TAG: "Node", _0: c, _1: l, _2: y, diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js index 5d66f89151..8ed6c0b347 100644 --- a/jscomp/test/rec_module_test.js +++ b/jscomp/test/rec_module_test.js @@ -107,7 +107,8 @@ function create(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -144,7 +145,8 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -176,7 +178,8 @@ function bal(l, v, r) { function add(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -207,7 +210,8 @@ function add(x, t) { } function singleton(x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -502,7 +506,8 @@ function cons_enum(_s, _e) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -567,7 +572,8 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -578,7 +584,8 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -946,7 +953,8 @@ function of_list(l) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -961,8 +969,10 @@ function of_list(l) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -985,15 +995,18 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/jscomp/test/recursive_records_test.js b/jscomp/test/recursive_records_test.js index 034bda5f33..cf39ab22c1 100644 --- a/jscomp/test/recursive_records_test.js +++ b/jscomp/test/recursive_records_test.js @@ -47,7 +47,8 @@ rec_cell2.next = rec_cell2; function f2(x) { var rec_cell2 = {}; - Caml_obj.update_dummy(rec_cell2, /* Cons */{ + Caml_obj.update_dummy(rec_cell2, { + TAG: "Cons", content: Math.imul(x, x) - 6 | 0, next: rec_cell2 }); diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index abf0485ba1..5be4594226 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -12,7 +12,8 @@ function cons_enum(_s, _e) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s._1, _1: s._2, _2: e @@ -229,7 +230,8 @@ function create(l, v, r) { hl = typeof l !== "object" ? 0 : l._3; var hr; hr = typeof r !== "object" ? 0 : r._3; - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -274,7 +276,8 @@ function internal_bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -329,7 +332,8 @@ function remove_min_elt(param) { } function singleton(x) { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: "Empty", @@ -445,7 +449,8 @@ function of_sorted_list(l) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", @@ -460,8 +465,10 @@ function of_sorted_list(l) { var match = l.tl; if (match) { return [ - /* Node */{ - _0: /* Node */{ + { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", @@ -484,15 +491,18 @@ function of_sorted_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - _0: /* Node */{ + { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", _3: 1 }, _1: match$1.hd, - _2: /* Node */{ + _2: { + TAG: "Node", _0: "Empty", _1: match$2.hd, _2: "Empty", @@ -541,7 +551,8 @@ function of_sorted_array(l) { } if (n === 1) { var x0 = l[start]; - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x0, _2: "Empty", @@ -551,8 +562,10 @@ function of_sorted_array(l) { if (n === 2) { var x0$1 = l[start]; var x1 = l[start + 1 | 0]; - return /* Node */{ - _0: /* Node */{ + return { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: x0$1, _2: "Empty", @@ -567,15 +580,18 @@ function of_sorted_array(l) { var x0$2 = l[start]; var x1$1 = l[start + 1 | 0]; var x2 = l[start + 2 | 0]; - return /* Node */{ - _0: /* Node */{ + return { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: x0$2, _2: "Empty", _3: 1 }, _1: x1$1, - _2: /* Node */{ + _2: { + TAG: "Node", _0: "Empty", _1: x2, _2: "Empty", diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index d87f52b90e..9fb703e624 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -43,7 +43,8 @@ function split(x, tree) { function add(x, tree) { if (typeof tree !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: "Empty", @@ -191,7 +192,8 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", _0: l1, _1: v1, _2: "Empty", @@ -202,7 +204,8 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", _0: "Empty", _1: v1, _2: r1, diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index e69e9d3774..e13603dda4 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -12,7 +12,8 @@ function fib(n) { } function cons(x, y) { - return /* Cons */{ + return { + TAG: "Cons", _0: x, _1: y }; @@ -22,7 +23,8 @@ function map(f, param) { if (typeof param !== "object") { return "Nil"; } else { - return /* Cons */{ + return { + TAG: "Cons", _0: Curry._1(f, param._0), _1: map(f, param._1) }; diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index 136e23d200..6d0f322d05 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -35,7 +35,8 @@ for(var i$1 = 10; i$1 >= 0; --i$1){ var sumdown = v$1; function cons(x, y) { - return /* Cons */{ + return { + TAG: "Cons", _0: x, _1: y }; @@ -53,7 +54,8 @@ function map(f, x) { if (typeof x !== "object") { return "Nil"; } else { - return /* Cons */{ + return { + TAG: "Cons", _0: Curry._1(f, x._0), _1: map(f, x._1) }; diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 054ba70ac8..094f35ed0f 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -15,7 +15,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -25,7 +26,8 @@ function create(l, x, d, r) { } function singleton(x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -64,7 +66,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -106,7 +109,8 @@ function is_empty(param) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -123,7 +127,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -487,7 +492,8 @@ function update(x, f, m) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -512,7 +518,8 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -557,7 +564,8 @@ function map(f, param) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -574,7 +582,8 @@ function mapi(f, param) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -840,7 +849,8 @@ function cons_enum(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/jscomp/test/test_int_map_find.js b/jscomp/test/test_int_map_find.js index fb92531eea..2ff25cea4f 100644 --- a/jscomp/test/test_int_map_find.js +++ b/jscomp/test/test_int_map_find.js @@ -14,7 +14,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -53,7 +54,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -87,7 +89,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -104,7 +107,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index 662c03c46c..d861c7b7db 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -16,7 +16,8 @@ function Make(Ord) { hl = typeof l !== "object" ? 0 : l._3; var hr; hr = typeof r !== "object" ? 0 : r._3; - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -52,7 +53,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", _0: l, _1: v, _2: r, @@ -83,7 +85,8 @@ function Make(Ord) { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: "Empty", @@ -103,7 +106,8 @@ function Make(Ord) { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", _0: "Empty", _1: x, _2: "Empty", @@ -346,7 +350,8 @@ function Make(Ord) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s._1, _1: s._2, _2: e @@ -409,7 +414,8 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", _0: l1, _1: v1, _2: "Empty", @@ -420,7 +426,8 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", _0: "Empty", _1: v1, _2: r1, @@ -583,7 +590,8 @@ function Make(Ord) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", @@ -598,8 +606,10 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - /* Node */{ - _0: /* Node */{ + { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", @@ -622,15 +632,18 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - _0: /* Node */{ + { + TAG: "Node", + _0: { + TAG: "Node", _0: "Empty", _1: l.hd, _2: "Empty", _3: 1 }, _1: match$1.hd, - _2: /* Node */{ + _2: { + TAG: "Node", _0: "Empty", _1: match$2.hd, _2: "Empty", diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index f75bc6435a..91ed2a5069 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -14,7 +14,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -53,7 +54,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -87,7 +89,8 @@ function bal(l, x, d, r) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -104,7 +107,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index ac5b5b020c..71cbc8561e 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -105,7 +105,8 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -115,7 +116,8 @@ function create(l, x, d, r) { } function singleton(x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -154,7 +156,8 @@ function bal(l, x, d, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -196,7 +199,8 @@ function is_empty(param) { function add(x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -213,7 +217,8 @@ function add(x, data, m) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -577,7 +582,8 @@ function update(x, f, m) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -602,7 +608,8 @@ function update(x, f, m) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -647,7 +654,8 @@ function map(f, param) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -664,7 +672,8 @@ function mapi(f, param) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -930,7 +939,8 @@ function cons_enum(_m, _e) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, @@ -1081,7 +1091,8 @@ function compute_update_sequences(all_tickers) { var match = ticker.type_; if (typeof match !== "object") { var counter$1 = counter + 1 | 0; - ticker.rank = /* Ranked */{ + ticker.rank = { + TAG: "Ranked", _0: counter$1 }; return counter$1; @@ -1090,7 +1101,8 @@ function compute_update_sequences(all_tickers) { var counter$2 = loop(counter, match$1.lhs); var counter$3 = loop(counter$2, match$1.rhs); var counter$4 = counter$3 + 1 | 0; - ticker.rank = /* Ranked */{ + ticker.rank = { + TAG: "Ranked", _0: counter$4 }; return counter$4; @@ -1204,7 +1216,8 @@ function process_input_line(ticker_map, all_tickers, line) { value: undefined, rank: "Uninitialized", ticker_name: ticker_name, - type_: /* Binary_op */{ + type_: { + TAG: "Binary_op", _0: { op: op, rhs: rhs$1, diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index c6c27954cf..f67b7745f0 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -463,7 +463,8 @@ function create(l, v, r) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -500,7 +501,8 @@ function bal(l, v, r) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -532,7 +534,8 @@ function bal(l, v, r) { function add(x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -563,7 +566,8 @@ function add(x, t) { } function singleton(x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -858,7 +862,8 @@ function cons_enum(_s, _e) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -923,7 +928,8 @@ function subset(_s1, _s2) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -934,7 +940,8 @@ function subset(_s1, _s2) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -1302,7 +1309,8 @@ function of_list(l) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1317,8 +1325,10 @@ function of_list(l) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1341,15 +1351,18 @@ function of_list(l) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index 26c224522f..cebb4dea6d 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -108,7 +108,8 @@ function copy_bucketlist(param) { var key = param.key; var data = param.data; var next = param.next; - var r = /* Cons */{ + var r = { + TAG: "Cons", key: key, data: data, next: next @@ -130,7 +131,8 @@ function copy_bucketlist(param) { continue ; }; }; - var r = /* Cons */{ + var r = { + TAG: "Cons", key: key, data: data, next: next @@ -172,7 +174,8 @@ function resize(indexfun, h) { var key = cell.key; var data = cell.data; var next = cell.next; - var cell$1 = inplace ? cell : /* Cons */({ + var cell$1 = inplace ? cell : ({ + TAG: "Cons", key: key, data: data, next: "Empty" @@ -210,7 +213,8 @@ function key_index(h, key) { function add(h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -401,7 +405,8 @@ function replace(h, key, data) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l @@ -603,7 +608,8 @@ function MakeSeeded(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -788,7 +794,8 @@ function MakeSeeded(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l @@ -845,7 +852,8 @@ function Make(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -1030,7 +1038,8 @@ function Make(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l diff --git a/lib/es6/map.js b/lib/es6/map.js index c89cf052bd..91a7429f04 100644 --- a/lib/es6/map.js +++ b/lib/es6/map.js @@ -14,7 +14,8 @@ function Make(funarg) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -23,7 +24,8 @@ function Make(funarg) { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -61,7 +63,8 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -101,7 +104,8 @@ function Make(funarg) { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -118,7 +122,8 @@ function Make(funarg) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -467,7 +472,8 @@ function Make(funarg) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -492,7 +498,8 @@ function Make(funarg) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -535,7 +542,8 @@ function Make(funarg) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -551,7 +559,8 @@ function Make(funarg) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -803,7 +812,8 @@ function Make(funarg) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/lib/es6/mapLabels.js b/lib/es6/mapLabels.js index 2adefdf504..f30f682b0e 100644 --- a/lib/es6/mapLabels.js +++ b/lib/es6/mapLabels.js @@ -14,7 +14,8 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -23,7 +24,8 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -61,7 +63,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -101,7 +104,8 @@ function Make(Ord) { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -118,7 +122,8 @@ function Make(Ord) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -467,7 +472,8 @@ function Make(Ord) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -492,7 +498,8 @@ function Make(Ord) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -535,7 +542,8 @@ function Make(Ord) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -551,7 +559,8 @@ function Make(Ord) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -803,7 +812,8 @@ function Make(Ord) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/lib/es6/moreLabels.js b/lib/es6/moreLabels.js index 9162d0adb5..b3dcca38d3 100644 --- a/lib/es6/moreLabels.js +++ b/lib/es6/moreLabels.js @@ -44,7 +44,8 @@ var $$Map = { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -53,7 +54,8 @@ var $$Map = { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -91,7 +93,8 @@ var $$Map = { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -131,7 +134,8 @@ var $$Map = { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -148,7 +152,8 @@ var $$Map = { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -497,7 +502,8 @@ var $$Map = { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -522,7 +528,8 @@ var $$Map = { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -565,7 +572,8 @@ var $$Map = { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -581,7 +589,8 @@ var $$Map = { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -833,7 +842,8 @@ var $$Map = { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, @@ -980,7 +990,8 @@ var $$Set = { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -1016,7 +1027,8 @@ var $$Set = { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -1047,7 +1059,8 @@ var $$Set = { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -1077,7 +1090,8 @@ var $$Set = { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -1358,7 +1372,8 @@ var $$Set = { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -1421,7 +1436,8 @@ var $$Set = { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -1432,7 +1448,8 @@ var $$Set = { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -1769,7 +1786,8 @@ var $$Set = { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1784,8 +1802,10 @@ var $$Set = { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1808,15 +1828,18 @@ var $$Set = { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/queue.js b/lib/es6/queue.js index 224dbf860a..d9282aa6ff 100644 --- a/lib/es6/queue.js +++ b/lib/es6/queue.js @@ -20,7 +20,8 @@ function clear(q) { } function add(x, q) { - var cell = /* Cons */{ + var cell = { + TAG: "Cons", content: x, next: "Nil" }; @@ -82,7 +83,8 @@ function copy(q) { return q_res; } var next = cell.next; - var res = /* Cons */{ + var res = { + TAG: "Cons", content: cell.content, next: "Nil" }; diff --git a/lib/es6/set.js b/lib/es6/set.js index d71f9a449e..62b4d3a55c 100644 --- a/lib/es6/set.js +++ b/lib/es6/set.js @@ -17,7 +17,8 @@ function Make(funarg) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -53,7 +54,8 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -84,7 +86,8 @@ function Make(funarg) { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -114,7 +117,8 @@ function Make(funarg) { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -392,7 +396,8 @@ function Make(funarg) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -454,7 +459,8 @@ function Make(funarg) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -465,7 +471,8 @@ function Make(funarg) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -816,7 +823,8 @@ function Make(funarg) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -831,8 +839,10 @@ function Make(funarg) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -855,15 +865,18 @@ function Make(funarg) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/es6/setLabels.js b/lib/es6/setLabels.js index a01d500cd2..6efa60a772 100644 --- a/lib/es6/setLabels.js +++ b/lib/es6/setLabels.js @@ -17,7 +17,8 @@ function Make(Ord) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -53,7 +54,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -84,7 +86,8 @@ function Make(Ord) { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -114,7 +117,8 @@ function Make(Ord) { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -395,7 +399,8 @@ function Make(Ord) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -458,7 +463,8 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -469,7 +475,8 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -806,7 +813,8 @@ function Make(Ord) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -821,8 +829,10 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -845,15 +855,18 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index fd8a848409..bdbb33cf5d 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -108,7 +108,8 @@ function copy_bucketlist(param) { var key = param.key; var data = param.data; var next = param.next; - var r = /* Cons */{ + var r = { + TAG: "Cons", key: key, data: data, next: next @@ -130,7 +131,8 @@ function copy_bucketlist(param) { continue ; }; }; - var r = /* Cons */{ + var r = { + TAG: "Cons", key: key, data: data, next: next @@ -172,7 +174,8 @@ function resize(indexfun, h) { var key = cell.key; var data = cell.data; var next = cell.next; - var cell$1 = inplace ? cell : /* Cons */({ + var cell$1 = inplace ? cell : ({ + TAG: "Cons", key: key, data: data, next: "Empty" @@ -210,7 +213,8 @@ function key_index(h, key) { function add(h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -401,7 +405,8 @@ function replace(h, key, data) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l @@ -603,7 +608,8 @@ function MakeSeeded(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -788,7 +794,8 @@ function MakeSeeded(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l @@ -845,7 +852,8 @@ function Make(H) { }; var add = function (h, key, data) { var i = key_index(h, key); - var bucket = /* Cons */{ + var bucket = { + TAG: "Cons", key: key, data: data, next: Caml_array.get(h.data, i) @@ -1030,7 +1038,8 @@ function Make(H) { var i = key_index(h, key); var l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { - Caml_array.set(h.data, i, /* Cons */{ + Caml_array.set(h.data, i, { + TAG: "Cons", key: key, data: data, next: l diff --git a/lib/js/map.js b/lib/js/map.js index 8ae3986486..3ceda28d16 100644 --- a/lib/js/map.js +++ b/lib/js/map.js @@ -14,7 +14,8 @@ function Make(funarg) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -23,7 +24,8 @@ function Make(funarg) { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -61,7 +63,8 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -101,7 +104,8 @@ function Make(funarg) { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -118,7 +122,8 @@ function Make(funarg) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -467,7 +472,8 @@ function Make(funarg) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -492,7 +498,8 @@ function Make(funarg) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -535,7 +542,8 @@ function Make(funarg) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -551,7 +559,8 @@ function Make(funarg) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -803,7 +812,8 @@ function Make(funarg) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/lib/js/mapLabels.js b/lib/js/mapLabels.js index 463c4e5ffd..79d4163c8f 100644 --- a/lib/js/mapLabels.js +++ b/lib/js/mapLabels.js @@ -14,7 +14,8 @@ function Make(Ord) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -23,7 +24,8 @@ function Make(Ord) { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -61,7 +63,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -101,7 +104,8 @@ function Make(Ord) { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -118,7 +122,8 @@ function Make(Ord) { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -467,7 +472,8 @@ function Make(Ord) { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -492,7 +498,8 @@ function Make(Ord) { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -535,7 +542,8 @@ function Make(Ord) { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -551,7 +559,8 @@ function Make(Ord) { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -803,7 +812,8 @@ function Make(Ord) { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, diff --git a/lib/js/moreLabels.js b/lib/js/moreLabels.js index 7c79b5b7b9..46d1a17ee2 100644 --- a/lib/js/moreLabels.js +++ b/lib/js/moreLabels.js @@ -44,7 +44,8 @@ var $$Map = { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -53,7 +54,8 @@ var $$Map = { }; }; var singleton = function (x, d) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: d, @@ -91,7 +93,8 @@ var $$Map = { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: d, @@ -131,7 +134,8 @@ var $$Map = { }; var add = function (x, data, m) { if (typeof m !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: data, @@ -148,7 +152,8 @@ var $$Map = { if (d === data) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data, @@ -497,7 +502,8 @@ var $$Map = { if (typeof m !== "object") { var data = Curry._1(f, undefined); if (data !== undefined) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, d: Caml_option.valFromOption(data), @@ -522,7 +528,8 @@ var $$Map = { if (d === data$2) { return m; } else { - return /* Node */{ + return { + TAG: "Node", l: l, v: x, d: data$2, @@ -565,7 +572,8 @@ var $$Map = { var l$p = map(f, param.l); var d$p = Curry._1(f, param.d); var r$p = map(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: param.v, d: d$p, @@ -581,7 +589,8 @@ var $$Map = { var l$p = mapi(f, param.l); var d$p = Curry._2(f, v, param.d); var r$p = mapi(f, param.r); - return /* Node */{ + return { + TAG: "Node", l: l$p, v: v, d: d$p, @@ -833,7 +842,8 @@ var $$Map = { if (typeof m !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: m.v, _1: m.d, _2: m.r, @@ -980,7 +990,8 @@ var $$Set = { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -1016,7 +1027,8 @@ var $$Set = { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -1047,7 +1059,8 @@ var $$Set = { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -1077,7 +1090,8 @@ var $$Set = { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -1358,7 +1372,8 @@ var $$Set = { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -1421,7 +1436,8 @@ var $$Set = { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -1432,7 +1448,8 @@ var $$Set = { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -1769,7 +1786,8 @@ var $$Set = { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1784,8 +1802,10 @@ var $$Set = { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -1808,15 +1828,18 @@ var $$Set = { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/queue.js b/lib/js/queue.js index a33c520d58..3fb8d780f0 100644 --- a/lib/js/queue.js +++ b/lib/js/queue.js @@ -20,7 +20,8 @@ function clear(q) { } function add(x, q) { - var cell = /* Cons */{ + var cell = { + TAG: "Cons", content: x, next: "Nil" }; @@ -82,7 +83,8 @@ function copy(q) { return q_res; } var next = cell.next; - var res = /* Cons */{ + var res = { + TAG: "Cons", content: cell.content, next: "Nil" }; diff --git a/lib/js/set.js b/lib/js/set.js index 8f8b83f85e..27847c6ad0 100644 --- a/lib/js/set.js +++ b/lib/js/set.js @@ -17,7 +17,8 @@ function Make(funarg) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -53,7 +54,8 @@ function Make(funarg) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -84,7 +86,8 @@ function Make(funarg) { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -114,7 +117,8 @@ function Make(funarg) { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -392,7 +396,8 @@ function Make(funarg) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -454,7 +459,8 @@ function Make(funarg) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -465,7 +471,8 @@ function Make(funarg) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -816,7 +823,8 @@ function Make(funarg) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -831,8 +839,10 @@ function Make(funarg) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -855,15 +865,18 @@ function Make(funarg) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", diff --git a/lib/js/setLabels.js b/lib/js/setLabels.js index c728ff6dbd..e7f53c9a7e 100644 --- a/lib/js/setLabels.js +++ b/lib/js/setLabels.js @@ -17,7 +17,8 @@ function Make(Ord) { hl = typeof l !== "object" ? 0 : l.h; var hr; hr = typeof r !== "object" ? 0 : r.h; - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -53,7 +54,8 @@ function Make(Ord) { }; } if (hr <= (hl + 2 | 0)) { - return /* Node */{ + return { + TAG: "Node", l: l, v: v, r: r, @@ -84,7 +86,8 @@ function Make(Ord) { }; var add = function (x, t) { if (typeof t !== "object") { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -114,7 +117,8 @@ function Make(Ord) { } }; var singleton = function (x) { - return /* Node */{ + return { + TAG: "Node", l: "Empty", v: x, r: "Empty", @@ -395,7 +399,8 @@ function Make(Ord) { if (typeof s !== "object") { return e; } - _e = /* More */{ + _e = { + TAG: "More", _0: s.v, _1: s.r, _2: e @@ -458,7 +463,8 @@ function Make(Ord) { continue ; } if (c < 0) { - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: l1, v: v1, r: "Empty", @@ -469,7 +475,8 @@ function Make(Ord) { _s1 = r1; continue ; } - if (!subset(/* Node */{ + if (!subset({ + TAG: "Node", l: "Empty", v: v1, r: r1, @@ -806,7 +813,8 @@ function Make(Ord) { case 1 : if (l) { return [ - /* Node */{ + { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -821,8 +829,10 @@ function Make(Ord) { var match = l.tl; if (match) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", @@ -845,15 +855,18 @@ function Make(Ord) { var match$2 = match$1.tl; if (match$2) { return [ - /* Node */{ - l: /* Node */{ + { + TAG: "Node", + l: { + TAG: "Node", l: "Empty", v: l.hd, r: "Empty", h: 1 }, v: match$1.hd, - r: /* Node */{ + r: { + TAG: "Node", l: "Empty", v: match$2.hd, r: "Empty", From 69a7e4198ce7f31673743afbe9b415350678411e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 23 Mar 2023 06:38:59 +0100 Subject: [PATCH 04/13] Support @as("foo") to customize the representation of tags. --- jscomp/core/js_dump.ml | 11 +++++++--- jscomp/core/lam_compile.ml | 20 +++++++++++------ jscomp/core/lam_compile_const.ml | 4 +++- jscomp/core/lam_compile_primitive.ml | 2 +- jscomp/core/lam_constant_convert.ml | 5 +++-- jscomp/core/lam_convert.ml | 2 +- jscomp/core/lam_print.ml | 4 ++-- jscomp/core/matching_polyfill.ml | 7 ++++-- jscomp/frontend/ast_attributes.ml | 5 +++++ jscomp/frontend/ast_attributes.mli | 2 ++ jscomp/frontend/lam_constant.ml | 4 ++-- jscomp/frontend/lam_constant.mli | 2 +- jscomp/ml/lambda.ml | 26 ++++++++++++---------- jscomp/ml/lambda.mli | 23 +++++++++---------- jscomp/ml/transl_recmodule.ml | 6 +++-- jscomp/ml/translcore.ml | 2 ++ jscomp/runtime/release.ninja | 6 ++--- jscomp/test/variantsMatching.js | 33 ++++++++++++++++++++++++++++ jscomp/test/variantsMatching.res | 18 +++++++++++++++ 19 files changed, 133 insertions(+), 49 deletions(-) diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index c358a5910b..86dd01edf2 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -771,7 +771,11 @@ and expression_desc cxt ~(level : int) f x : cxt = | Undefined when is_optional f -> None | _ -> Some (f, x)) in - (Js_op.Lit L.tag, E.str p.name) :: tails + ( Js_op.Lit L.tag, + match Ast_attributes.process_as_value p.attrs with + | None -> E.str p.name + | Some (AsString s) -> E.str s ) + :: tails in expression_desc cxt ~level f (Object objs) | Caml_block (el, _, tag, Blk_constructor p) -> @@ -792,8 +796,9 @@ and expression_desc cxt ~(level : int) f x : cxt = if not_is_cons = false && p.num_nonconst = 1 then tails else ( Js_op.Lit L.tag, - E.str p.name - ) + match Ast_attributes.process_as_value p.attrs with + | None -> E.str p.name + | Some (AsString s) -> E.str s ) :: tails in expression_desc cxt ~level f (Object objs) diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 06c3055d0d..79f0e42217 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -453,8 +453,8 @@ and compile_recursive_lets cxt id_args : Js_output.t = Js_output.append_output acc (compile_recursive_lets_aux cxt x))) and compile_general_cases : - 'a. - ('a -> string option) -> + 'a . + ('a -> Lambda.cstr_name option) -> ('a -> J.expression) -> (J.expression -> J.expression -> J.expression) -> Lam_compile_context.t -> @@ -467,7 +467,7 @@ and compile_general_cases : ('a * Lam.t) list -> default_case -> J.block = - fun (make_comment : _ -> string option) (make_exp : _ -> J.expression) + fun (get_cstr_name : _ -> Lambda.cstr_name option) (make_exp : _ -> J.expression) (eq_exp : J.expression -> J.expression -> J.expression) (cxt : Lam_compile_context.t) (switch : @@ -531,6 +531,9 @@ and compile_general_cases : | Default lam -> Some (Js_output.output_as_block (compile_lambda cxt lam)) in + let make_comment i = match get_cstr_name i with + | None -> None + | Some {name} -> Some name in let body = group_apply cases (fun last (switch_case, lam) -> if last then @@ -569,16 +572,19 @@ and compile_general_cases : and compile_cases cxt (switch_exp : E.t) table default get_name = let string_table = table |> List.filter_map (fun (i, lam) -> match get_name i - with None -> None - | Some n -> Some (n, lam)) in + with + | None -> None + | Some {Lambda.as_value= Some (AsString s)} -> Some (s, lam) + | Some {name; as_value = None} -> Some (name, lam)) in if List.length string_table = List.length table then compile_string_cases cxt switch_exp string_table default else compile_general_cases get_name (fun i -> match get_name i with - | None -> E.small_int i - | Some name -> E.str name) + | None -> E.small_int i + | Some {as_value = Some(AsString s)} -> E.str s + | Some {name} -> E.str name) E.int_equal cxt (fun ?default ?declaration e clauses -> S.int_switch ?default ?declaration e clauses) diff --git a/jscomp/core/lam_compile_const.ml b/jscomp/core/lam_compile_const.ml index 75aec054e0..838d03da22 100644 --- a/jscomp/core/lam_compile_const.ml +++ b/jscomp/core/lam_compile_const.ml @@ -47,8 +47,10 @@ and translate (x : Lam_constant.t) : J.expression = | Const_js_false -> E.bool false | Const_js_null -> E.nil | Const_js_undefined -> E.undefined - | Const_int { i; comment = Pt_constructor {name}} when name <> "[]" -> + | Const_int { i; comment = Pt_constructor {cstr_name={name; as_value=None}}} when name <> "[]" -> E.str name + | Const_int { i; comment = Pt_constructor {cstr_name={as_value = Some (AsString s)}}} -> + E.str s | Const_int { i; comment } -> E.int i ?comment:(Lam_constant.string_of_pointer_info comment) | Const_char i -> Js_of_lam_string.const_char i diff --git a/jscomp/core/lam_compile_primitive.ml b/jscomp/core/lam_compile_primitive.ml index 17932ff6db..6a54005e6a 100644 --- a/jscomp/core/lam_compile_primitive.ml +++ b/jscomp/core/lam_compile_primitive.ml @@ -300,7 +300,7 @@ let translate loc (cxt : Lam_compile_context.t) (prim : Lam_primitive.t) (* 2 ^ 32 - 1*) | Backend_type -> E.make_block E.zero_int_literal - (Blk_constructor { name = "Other"; num_nonconst = 1; tag = 0 }) + (Blk_constructor { name = "Other"; num_nonconst = 1; tag = 0; attrs = [] }) [ E.str "BS" ] Immutable) | Pduprecord -> Lam_dispatch_primitive.translate loc "?obj_dup" args | Plazyforce diff --git a/jscomp/core/lam_constant_convert.ml b/jscomp/core/lam_constant_convert.ml index 50b76e2ee2..7fe9a4ca51 100644 --- a/jscomp/core/lam_constant_convert.ml +++ b/jscomp/core/lam_constant_convert.ml @@ -48,11 +48,12 @@ let rec convert_constant (const : Lambda.structured_constant) : Lam_constant.t = | Pt_shape_none -> Lam_constant.lam_none | Pt_assertfalse -> Const_int { i = Int32.of_int i; comment = Pt_assertfalse } - | Pt_constructor { name; const; non_const } -> + | Pt_constructor { name; const; non_const; attrs } -> + let as_value = Ast_attributes.process_as_value attrs in Const_int { i = Int32.of_int i; - comment = Pt_constructor { name; const; non_const }; + comment = Pt_constructor { cstr_name={name; as_value}; const; non_const }; } | Pt_variant { name } -> if Ext_string.is_valid_hash_number name then diff --git a/jscomp/core/lam_convert.ml b/jscomp/core/lam_convert.ml index 87266c46d3..e3d0b1d4f1 100644 --- a/jscomp/core/lam_convert.ml +++ b/jscomp/core/lam_convert.ml @@ -473,7 +473,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : | "#makemutablelist" -> Pmakeblock ( 0, - Blk_constructor { name = "::"; num_nonconst = 1; tag = 0 }, + Blk_constructor { name = "::"; num_nonconst = 1; tag = 0; attrs = [] }, Mutable ) | "#undefined_to_opt" -> Pundefined_to_opt | "#nullable_to_opt" -> Pnull_undefined_to_opt diff --git a/jscomp/core/lam_print.ml b/jscomp/core/lam_print.ml index b6cb43989a..9860bb3788 100644 --- a/jscomp/core/lam_print.ml +++ b/jscomp/core/lam_print.ml @@ -313,14 +313,14 @@ let lambda ppf v = (fun (n, l) -> if !spc then fprintf ppf "@ " else spc := true; fprintf ppf "@[case int %i %S:@ %a@]" n - (match sw.sw_names with None -> "" | Some x -> x.consts.(n)) + (match sw.sw_names with None -> "" | Some x -> x.consts.(n).name) lam l) sw.sw_consts; List.iter (fun (n, l) -> if !spc then fprintf ppf "@ " else spc := true; fprintf ppf "@[case tag %i %S:@ %a@]" n - (match sw.sw_names with None -> "" | Some x -> x.blocks.(n)) + (match sw.sw_names with None -> "" | Some x -> x.blocks.(n).name) lam l) sw.sw_blocks; match sw.sw_failaction with diff --git a/jscomp/core/matching_polyfill.ml b/jscomp/core/matching_polyfill.ml index ba32293fb2..3b04c59aa2 100644 --- a/jscomp/core/matching_polyfill.ml +++ b/jscomp/core/matching_polyfill.ml @@ -27,11 +27,14 @@ let is_nullary_variant (x : Types.constructor_arguments) = let names_from_construct_pattern (pat : Typedtree.pattern) = let names_from_type_variant (cstrs : Types.constructor_declaration list) = + let get_cstr_name (cstr: Types.constructor_declaration) = + { Lambda.name = Ident.name cstr.cd_id; + as_value = Ast_attributes.process_as_value cstr.cd_attributes } in let consts, blocks = Ext_list.fold_left cstrs ([], []) (fun (consts, blocks) cstr -> if is_nullary_variant cstr.cd_args then - (Ident.name cstr.cd_id :: consts, blocks) - else (consts, Ident.name cstr.cd_id :: blocks)) + (get_cstr_name cstr :: consts, blocks) + else (consts, get_cstr_name cstr :: blocks)) in Some { diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index 4fa0ac3792..19b1114595 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -256,6 +256,11 @@ let iter_process_bs_string_as (attrs : t) : string option = | _ -> ()); !st +let process_as_value attrs : Lambda.as_value option = + match iter_process_bs_string_as attrs with + | None -> None + | Some s -> Some (AsString s) + let has_bs_optional (attrs : t) : bool = Ext_list.exists attrs (fun (({ txt }, _) as attr) -> match txt with diff --git a/jscomp/frontend/ast_attributes.mli b/jscomp/frontend/ast_attributes.mli index 9897790dfc..ed9ebfa34b 100644 --- a/jscomp/frontend/ast_attributes.mli +++ b/jscomp/frontend/ast_attributes.mli @@ -91,3 +91,5 @@ val internal_expansive : attr val rs_externals : t -> string list -> bool val process_send_pipe : t -> (Parsetree.core_type * t) option + +val process_as_value : t -> Lambda.as_value option \ No newline at end of file diff --git a/jscomp/frontend/lam_constant.ml b/jscomp/frontend/lam_constant.ml index 9c87a24cdb..d0a4986e0b 100644 --- a/jscomp/frontend/lam_constant.ml +++ b/jscomp/frontend/lam_constant.ml @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type constructor_tag = { name : string; const : int; non_const : int } +type constructor_tag = { cstr_name : Lambda.cstr_name; const : int; non_const : int } type pointer_info = | None @@ -32,7 +32,7 @@ type pointer_info = let string_of_pointer_info (x : pointer_info) : string option = match x with - | Some name | Pt_constructor { name; _ } -> Some name + | Some name | Pt_constructor { cstr_name={name}; _ } -> Some name | Pt_assertfalse -> Some "assert_false" | None -> None diff --git a/jscomp/frontend/lam_constant.mli b/jscomp/frontend/lam_constant.mli index 51639dd4e0..a12ba99389 100644 --- a/jscomp/frontend/lam_constant.mli +++ b/jscomp/frontend/lam_constant.mli @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type constructor_tag = { name : string; const : int; non_const : int } +type constructor_tag = { cstr_name : Lambda.cstr_name; const : int; non_const : int } type pointer_info = | None diff --git a/jscomp/ml/lambda.ml b/jscomp/ml/lambda.ml index 9437253a63..dd75f9bbb4 100644 --- a/jscomp/ml/lambda.ml +++ b/jscomp/ml/lambda.ml @@ -38,9 +38,12 @@ type record_repr = | Record_regular | Record_optional +type as_value = AsString of string +type cstr_name = {name: string; as_value: as_value option} + type tag_info = - | Blk_constructor of {name : string ; num_nonconst : int ; tag : int } - | Blk_record_inlined of { name : string ; num_nonconst : int; tag : int; optional_labels: string list; fields : string array; mutable_flag : Asttypes.mutable_flag } + | Blk_constructor of {name : string ; num_nonconst : int ; tag : int; attrs : Parsetree.attributes } + | Blk_record_inlined of { name : string ; num_nonconst : int; tag : int; optional_labels: string list; fields : string array; mutable_flag : Asttypes.mutable_flag; attrs : Parsetree.attributes } | Blk_tuple | Blk_poly_var of string | Blk_record of {fields : string array; mutable_flag : Asttypes.mutable_flag; record_repr : record_repr} @@ -98,7 +101,7 @@ let blk_record_ext = ref (fun fields mutable_flag -> let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag mutable_flag -> let fields = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in - Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels} + Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs = []} ) let ref_tag_info : tag_info = @@ -233,12 +236,11 @@ and raise_kind = | Raise_reraise | Raise_notrace -type pointer_info = - | Pt_constructor of {name : string; const : int ; non_const : int } - | Pt_variant of {name : string} - | Pt_module_alias - - | Pt_shape_none +type pointer_info = + | Pt_constructor of {name: string; const: int; non_const: int; attrs: Parsetree.attributes} + | Pt_variant of {name: string} + | Pt_module_alias + | Pt_shape_none | Pt_assertfalse @@ -271,7 +273,7 @@ type function_attribute = { return_unit : bool; async : bool; } -type switch_names = {consts: string array; blocks: string array} +type switch_names = {consts: cstr_name array; blocks: cstr_name array} type lambda = Lvar of Ident.t @@ -323,7 +325,9 @@ and lambda_switch = not necessary "()", it can be used as a place holder for module alias etc. *) -let const_unit = Const_pointer(0, Pt_constructor{name = "()"; const = 1; non_const = 0}) +let const_unit = + Const_pointer + (0, Pt_constructor {name = "()"; const = 1; non_const = 0; attrs = []}) let lambda_assert_false = Lconst (Const_pointer(0, Pt_assertfalse)) diff --git a/jscomp/ml/lambda.mli b/jscomp/ml/lambda.mli index 2be51ec909..34af9ceb4d 100644 --- a/jscomp/ml/lambda.mli +++ b/jscomp/ml/lambda.mli @@ -38,9 +38,12 @@ type record_repr = | Record_regular | Record_optional +type as_value = AsString of string +type cstr_name = {name:string; as_value: as_value option} + type tag_info = - | Blk_constructor of {name : string ; num_nonconst : int; tag : int} - | Blk_record_inlined of { name : string ; num_nonconst : int ; tag : int; optional_labels: string list; fields : string array; mutable_flag : mutable_flag } + | Blk_constructor of { name : string ; num_nonconst : int; tag : int; attrs : Parsetree.attributes } + | Blk_record_inlined of { name : string ; num_nonconst : int ; tag : int; optional_labels: string list; fields : string array; mutable_flag : mutable_flag; attrs : Parsetree.attributes } | Blk_tuple | Blk_poly_var of string | Blk_record of {fields : string array; mutable_flag : mutable_flag; record_repr : record_repr } @@ -86,7 +89,7 @@ val blk_record_inlined : string -> int -> string list -> - tag:int -> + tag:int -> mutable_flag -> tag_info ) ref @@ -134,15 +137,13 @@ type is_safe = | Safe | Unsafe -type pointer_info = - | Pt_constructor of {name : string; const : int ; non_const : int} - | Pt_variant of {name : string} - | Pt_module_alias - | Pt_shape_none +type pointer_info = + | Pt_constructor of {name: string; const: int; non_const: int; attrs: Parsetree.attributes} + | Pt_variant of {name: string} + | Pt_module_alias + | Pt_shape_none | Pt_assertfalse - - type primitive = | Pidentity | Pbytes_to_string @@ -274,7 +275,7 @@ type function_attribute = { async : bool; } -type switch_names = {consts: string array; blocks: string array} +type switch_names = {consts: cstr_name array; blocks: cstr_name array} type lambda = Lvar of Ident.t diff --git a/jscomp/ml/transl_recmodule.ml b/jscomp/ml/transl_recmodule.ml index 99425fbff1..3e709b6dc3 100644 --- a/jscomp/ml/transl_recmodule.ml +++ b/jscomp/ml/transl_recmodule.ml @@ -31,10 +31,10 @@ let init_shape modl = (Blk_tuple, [ x; Const_base (Const_string (Ident.name id, None)) ]) in let module_tag_info : Lambda.tag_info = - Blk_constructor { name = "Module"; num_nonconst = 2; tag = 0 } + Blk_constructor { name="Module"; num_nonconst = 2; tag = 0; attrs = [] } in let value_tag_info : Lambda.tag_info = - Blk_constructor { name = "value"; num_nonconst = 2; tag = 1 } + Blk_constructor { name = "value"; num_nonconst = 2; tag = 1; attrs = [] } in let rec init_shape_mod env mty = match Mtype.scrape env mty with @@ -61,6 +61,7 @@ let init_shape modl = name = "Function"; const = cstr_const; non_const = cstr_non_const; + attrs = []; } ) | { desc = Tconstr (p, _, _) } when Path.same p Predef.path_lazy_t -> Const_pointer @@ -70,6 +71,7 @@ let init_shape modl = name = "Lazy"; const = cstr_const; non_const = cstr_non_const; + attrs = []; } ) | _ -> raise Not_found in diff --git a/jscomp/ml/translcore.ml b/jscomp/ml/translcore.ml index 0854908dd4..ad0c8402d9 100644 --- a/jscomp/ml/translcore.ml +++ b/jscomp/ml/translcore.ml @@ -816,6 +816,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts; + attrs = cstr.cstr_attributes; } )) | Cstr_unboxed -> ( match ll with [ v ] -> v | _ -> assert false) | Cstr_block n -> ( @@ -834,6 +835,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = name = cstr.cstr_name; num_nonconst = cstr.cstr_nonconsts; tag = n; + attrs = cstr.cstr_attributes; } in try Lconst (Const_block (tag_info, List.map extract_constant ll)) diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index 24665ce5e3..8798a72d19 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -21,7 +21,7 @@ o runtime/caml_bytes.cmj : cc_cmi runtime/caml_bytes.ml | runtime/caml_bytes.cmi o runtime/caml_bytes.cmi : cc runtime/caml_bytes.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float.cmj : cc_cmi runtime/caml_float.ml | runtime/caml_float.cmi runtime/caml_float_extern.cmj o runtime/caml_float.cmi : cc runtime/caml_float.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj +o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml.cmj runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj o runtime/caml_format.cmi : cc runtime/caml_format.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_hash.cmj : cc_cmi runtime/caml_hash.ml | runtime/caml_hash.cmi runtime/caml_hash_primitive.cmj runtime/caml_nativeint_extern.cmj runtime/js.cmj o runtime/caml_hash.cmi : cc runtime/caml_hash.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj @@ -37,7 +37,7 @@ o runtime/caml_md5.cmj : cc_cmi runtime/caml_md5.ml | runtime/caml_array_extern. o runtime/caml_md5.cmi : cc runtime/caml_md5.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_module.cmj : cc_cmi runtime/caml_module.ml | runtime/caml_array_extern.cmj runtime/caml_module.cmi runtime/caml_obj.cmj o runtime/caml_module.cmi : cc runtime/caml_module.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.ml | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj +o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.ml | runtime/caml.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj o runtime/caml_obj.cmi : cc runtime/caml_obj.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_option.cmj : cc_cmi runtime/caml_option.ml | runtime/caml_option.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj o runtime/caml_option.cmi : cc runtime/caml_option.mli | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj @@ -54,7 +54,7 @@ o runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj : cc runtime/caml_exce o runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj : cc runtime/caml_int64_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/js.cmi runtime/js.cmj +o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/caml_option.cmj runtime/js.cmi runtime/js.cmj o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runtime/caml_nativeint_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index 0f01f32e67..024069ea05 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -134,6 +134,38 @@ function third2(l) { } } +function foo(x) { + if (typeof x === "object") { + if (x.TAG === "qq") { + return 4; + } else { + return 5; + } + } + switch (x) { + case "dd" : + return 1; + case "B" : + return 2; + case "C" : + return 3; + + } +} + +var CustomizeTags_d = { + TAG: "qq", + _0: 42 +}; + +var CustomizeTags = { + foo: foo, + a: "dd", + b: "B", + c: "C", + d: CustomizeTags_d +}; + exports.toEnum = toEnum; exports.toString = toString; exports.bar = bar; @@ -144,4 +176,5 @@ exports.st = st; exports.showToJs = showToJs; exports.third = third; exports.third2 = third2; +exports.CustomizeTags = CustomizeTags; /* No side effect */ diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index a95c89c8ed..00cc32a060 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -79,3 +79,21 @@ let third2 = l => | Cons(1, Cons(2, Cons(3, Empty))) => true | _ => false } + +module CustomizeTags = { + type t = | @as("dd") A | B | C | @as("qq") D(int) | E(int) + + let foo = x => + switch x { + | A => 1 + | B => 2 + | C => 3 + | D(_) => 4 + | E(_) => 5 + } + + let a = A + let b = B + let c = C + let d = D(42) +} From 80a4ee30388468ee52f760dd6d359e276a21af12 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 23 Mar 2023 06:55:34 +0100 Subject: [PATCH 05/13] Cleanup: chatgpt's suggestion --- jscomp/core/lam_compile.ml | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 79f0e42217..ab372bb71a 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -570,26 +570,27 @@ and compile_general_cases : [ switch ?default ?declaration switch_exp body ]) +and all_cases_have_name table get_name = + List.fold_right (fun (i, lam) acc -> + match get_name i, acc with + | Some {Lambda.as_value= Some (AsString s)}, Some string_table -> Some ((s, lam) :: string_table) + | Some {name; as_value = None}, Some string_table -> Some ((name, lam) :: string_table) + | _, _ -> None + ) table (Some []) and compile_cases cxt (switch_exp : E.t) table default get_name = - let string_table = table |> List.filter_map (fun (i, lam) -> match get_name i - with - | None -> None - | Some {Lambda.as_value= Some (AsString s)} -> Some (s, lam) - | Some {name; as_value = None} -> Some (name, lam)) in - if List.length string_table = List.length table - then - compile_string_cases cxt switch_exp string_table default - else - compile_general_cases get_name - (fun i -> match get_name i with - | None -> E.small_int i - | Some {as_value = Some(AsString s)} -> E.str s - | Some {name} -> E.str name) - E.int_equal cxt - (fun ?default ?declaration e clauses -> - S.int_switch ?default ?declaration e clauses) - switch_exp table default - + match all_cases_have_name table get_name with + | Some string_table -> compile_string_cases cxt switch_exp string_table default + | None -> + compile_general_cases get_name + (fun i -> match get_name i with + | None -> E.small_int i + | Some {as_value = Some(AsString s)} -> E.str s + | Some {name} -> E.str name) + E.int_equal cxt + (fun ?default ?declaration e clauses -> + S.int_switch ?default ?declaration e clauses) + switch_exp table default + and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) (lambda_cxt : Lam_compile_context.t) = (* TODO: if default is None, we can do some optimizations From dbe35705300565b30c7dd08457f9287277d0b745 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 23 Mar 2023 11:46:33 +0100 Subject: [PATCH 06/13] Add support for custom representation of the form `@as(12)` --- jscomp/core/j.ml | 2 +- jscomp/core/js_dump.ml | 12 ++++++--- jscomp/core/js_of_lam_variant.ml | 12 ++++----- jscomp/core/js_stmt_make.ml | 7 +++-- jscomp/core/js_stmt_make.mli | 2 +- jscomp/core/lam_compile.ml | 10 ++++--- jscomp/core/lam_compile_const.ml | 6 +++-- jscomp/frontend/ast_attributes.ml | 13 +++++----- jscomp/ml/lambda.ml | 2 +- jscomp/ml/lambda.mli | 2 +- jscomp/test/variantsMatching.js | 43 +++++++++++++++++++------------ jscomp/test/variantsMatching.res | 4 ++- 12 files changed, 72 insertions(+), 43 deletions(-) diff --git a/jscomp/core/j.ml b/jscomp/core/j.ml index 562246c6b2..34692371b6 100644 --- a/jscomp/core/j.ml +++ b/jscomp/core/j.ml @@ -254,7 +254,7 @@ and case_clause = { comment : string option; } -and string_clause = string * case_clause +and string_clause = Lambda.as_value * case_clause and int_clause = int * case_clause and statement_desc = diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 86dd01edf2..1020bd37e4 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -774,7 +774,8 @@ and expression_desc cxt ~(level : int) f x : cxt = ( Js_op.Lit L.tag, match Ast_attributes.process_as_value p.attrs with | None -> E.str p.name - | Some (AsString s) -> E.str s ) + | Some (AsString s) -> E.str s + | Some (AsInt i) -> E.small_int i ) :: tails in expression_desc cxt ~level f (Object objs) @@ -798,7 +799,8 @@ and expression_desc cxt ~(level : int) f x : cxt = ( Js_op.Lit L.tag, match Ast_attributes.process_as_value p.attrs with | None -> E.str p.name - | Some (AsString s) -> E.str s ) + | Some (AsString s) -> E.str s + | Some (AsInt i) -> E.small_int i ) :: tails in expression_desc cxt ~level f (Object objs) @@ -1193,7 +1195,11 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt = let cxt = P.paren_group f 1 (fun _ -> expression ~level:0 cxt f e) in P.space f; P.brace_vgroup f 1 (fun _ -> - let pp_string f txt = ignore @@ expression_desc cxt ~level:0 f (Str {txt; delim=DStarJ}) in + let pp_string f (as_value: Lambda.as_value) = + let e = match as_value with + | AsString txt -> E.str txt ~delim:DStarJ + | AsInt i -> E.small_int i in + ignore @@ expression_desc cxt ~level:0 f e.expression_desc in let cxt = loop_case_clauses cxt f pp_string cc in match def with | None -> cxt diff --git a/jscomp/core/js_of_lam_variant.ml b/jscomp/core/js_of_lam_variant.ml index 1f2bbc0235..6c3b6fb499 100644 --- a/jscomp/core/js_of_lam_variant.ml +++ b/jscomp/core/js_of_lam_variant.ml @@ -39,8 +39,8 @@ let eval (arg : J.expression) (dispatches : (string * string) list) : E.t = E.of_block [ S.string_switch arg - (Ext_list.map dispatches (fun (i, r) -> - ( i, + (Ext_list.map dispatches (fun (s, r) -> + ( Lambda.AsString s, J. { switch_body = [ S.return_stmt (E.str r) ]; @@ -79,8 +79,8 @@ let eval_as_event (arg : J.expression) [ S.string_switch (E.poly_var_tag_access arg) - (Ext_list.map dispatches (fun (i, r) -> - ( i, + (Ext_list.map dispatches (fun (s, r) -> + ( Lambda.AsString s, J. { switch_body = [ S.return_stmt (E.str r) ]; @@ -107,8 +107,8 @@ let eval_as_int (arg : J.expression) (dispatches : (string * int) list) : E.t = E.of_block [ S.string_switch arg - (Ext_list.map dispatches (fun (i, r) -> - ( i, + (Ext_list.map dispatches (fun (s, r) -> + ( Lambda.AsString s, J. { switch_body = diff --git a/jscomp/core/js_stmt_make.ml b/jscomp/core/js_stmt_make.ml index 4a8968375c..88f755f063 100644 --- a/jscomp/core/js_stmt_make.ml +++ b/jscomp/core/js_stmt_make.ml @@ -129,13 +129,16 @@ let int_switch ?(comment : string option) let string_switch ?(comment : string option) ?(declaration : (J.property * Ident.t) option) ?(default : J.block option) - (e : J.expression) (clauses : (string * J.case_clause) list) : t = + (e : J.expression) (clauses : (Lambda.as_value * J.case_clause) list) : t = match e.expression_desc with | Str {txt} -> ( let continuation = match Ext_list.find_opt clauses (fun (switch_case, x) -> - if switch_case = txt then Some x.switch_body else None) + match switch_case with + | AsString s -> + if s = txt then Some x.switch_body else None + | AsInt _ -> None) with | Some case -> case | None -> ( match default with Some x -> x | None -> assert false) diff --git a/jscomp/core/js_stmt_make.mli b/jscomp/core/js_stmt_make.mli index 2b800c966f..adda763c25 100644 --- a/jscomp/core/js_stmt_make.mli +++ b/jscomp/core/js_stmt_make.mli @@ -77,7 +77,7 @@ val string_switch : ?declaration:Lam_compat.let_kind * Ident.t -> ?default:J.block -> J.expression -> - (string * J.case_clause) list -> + (Lambda.as_value * J.case_clause) list -> t val declare_variable : diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index ab372bb71a..9f3d6a0076 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -573,8 +573,8 @@ and compile_general_cases : and all_cases_have_name table get_name = List.fold_right (fun (i, lam) acc -> match get_name i, acc with - | Some {Lambda.as_value= Some (AsString s)}, Some string_table -> Some ((s, lam) :: string_table) - | Some {name; as_value = None}, Some string_table -> Some ((name, lam) :: string_table) + | Some {Lambda.as_value= Some as_value}, Some string_table -> Some ((as_value, lam) :: string_table) + | Some {name; as_value = None}, Some string_table -> Some ((AsString name, lam) :: string_table) | _, _ -> None ) table (Some []) and compile_cases cxt (switch_exp : E.t) table default get_name = @@ -667,7 +667,10 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) and compile_string_cases cxt switch_exp table default = compile_general_cases (fun _ -> None) - (fun str -> E.str str ~delim:DStarJ) E.string_equal cxt + (fun (as_value: Lambda.as_value) -> match as_value with + | AsString s -> E.str s ~delim:DStarJ + | AsInt i -> E.small_int i) + E.string_equal cxt (fun ?default ?declaration e clauses -> S.string_switch ?default ?declaration e clauses) switch_exp table default @@ -679,6 +682,7 @@ and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) = Be careful: we should avoid multiple evaluation of l, The [gen] can be elimiated when number of [cases] is less than 3 *) + let cases = cases |> List.map (fun (s,l) -> Lambda.AsString s, l) in match compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } l with diff --git a/jscomp/core/lam_compile_const.ml b/jscomp/core/lam_compile_const.ml index 838d03da22..daeeced978 100644 --- a/jscomp/core/lam_compile_const.ml +++ b/jscomp/core/lam_compile_const.ml @@ -49,8 +49,10 @@ and translate (x : Lam_constant.t) : J.expression = | Const_js_undefined -> E.undefined | Const_int { i; comment = Pt_constructor {cstr_name={name; as_value=None}}} when name <> "[]" -> E.str name - | Const_int { i; comment = Pt_constructor {cstr_name={as_value = Some (AsString s)}}} -> - E.str s + | Const_int { i; comment = Pt_constructor {cstr_name={as_value = Some as_value}}} -> + ( match as_value with + | AsString s -> E.str s + | AsInt i -> E.small_int i) | Const_int { i; comment } -> E.int i ?comment:(Lam_constant.string_of_pointer_info comment) | Const_char i -> Js_of_lam_string.const_char i diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index 19b1114595..e603ee0c0e 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -255,12 +255,6 @@ let iter_process_bs_string_as (attrs : t) : string option = else Bs_syntaxerr.err loc Duplicated_bs_as | _ -> ()); !st - -let process_as_value attrs : Lambda.as_value option = - match iter_process_bs_string_as attrs with - | None -> None - | Some s -> Some (AsString s) - let has_bs_optional (attrs : t) : bool = Ext_list.exists attrs (fun (({ txt }, _) as attr) -> match txt with @@ -340,6 +334,13 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) = | _ -> ()); !st +let process_as_value attrs : Lambda.as_value option = + match iter_process_bs_string_or_int_as attrs with + | None -> None + | Some (Str (s, _)) -> Some (AsString s) + | Some (Int i) -> Some (AsInt i) + + let locg = Location.none (* let bs : attr = {txt = "bs" ; loc = locg}, Ast_payload.empty *) diff --git a/jscomp/ml/lambda.ml b/jscomp/ml/lambda.ml index dd75f9bbb4..b5369f12cf 100644 --- a/jscomp/ml/lambda.ml +++ b/jscomp/ml/lambda.ml @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string +type as_value = AsString of string | AsInt of int type cstr_name = {name: string; as_value: as_value option} type tag_info = diff --git a/jscomp/ml/lambda.mli b/jscomp/ml/lambda.mli index 34af9ceb4d..15917dc514 100644 --- a/jscomp/ml/lambda.mli +++ b/jscomp/ml/lambda.mli @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string +type as_value = AsString of string | AsInt of int type cstr_name = {name:string; as_value: as_value option} type tag_info = diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index 024069ea05..a27ba04509 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -135,21 +135,26 @@ function third2(l) { } function foo(x) { - if (typeof x === "object") { - if (x.TAG === "qq") { - return 4; - } else { - return 5; + if (typeof x !== "object") { + switch (x) { + case "dd" : + return 1; + case 12 : + return 2; + case "C" : + return 3; + + } + } else { + switch (x.TAG) { + case "qq" : + return 4; + case 42 : + return 5; + case "F" : + return 6; + } - } - switch (x) { - case "dd" : - return 1; - case "B" : - return 2; - case "C" : - return 3; - } } @@ -158,12 +163,18 @@ var CustomizeTags_d = { _0: 42 }; +var CustomizeTags_e = { + TAG: 42, + _0: 0 +}; + var CustomizeTags = { foo: foo, a: "dd", - b: "B", + b: 12, c: "C", - d: CustomizeTags_d + d: CustomizeTags_d, + e: CustomizeTags_e }; exports.toEnum = toEnum; diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index 00cc32a060..7190b688c5 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -81,7 +81,7 @@ let third2 = l => } module CustomizeTags = { - type t = | @as("dd") A | B | C | @as("qq") D(int) | E(int) + type t = | @as("dd") A | @as(12) B | C | @as("qq") D(int) | @as(42) E(int) | F(string) let foo = x => switch x { @@ -90,10 +90,12 @@ module CustomizeTags = { | C => 3 | D(_) => 4 | E(_) => 5 + | F(_) => 6 } let a = A let b = B let c = C let d = D(42) + let e = E(0) } From 5b28cb57dfb16c4edb02167502e9c9cc702e1027 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 23 Mar 2023 16:53:50 +0100 Subject: [PATCH 07/13] Add null, undefined, unboxed customization. null and undefined can only be applied to cases with no payloads unboxed can only be applied when there is exactly one case with payloads, and that case takes exactly one argument Some of those checks are possible statically. Not all of them are implemented. Some checks cannot if one wants to have user-level nullable, null, undefined types with pattern matching. E.g. null type could take null as an argument. --- jscomp/core/js_dump.ml | 25 ++--- jscomp/core/js_exp_make.ml | 29 ++++- jscomp/core/js_exp_make.mli | 5 +- jscomp/core/js_stmt_make.ml | 2 +- jscomp/core/lam_compile.ml | 18 +++- jscomp/core/lam_compile_const.ml | 4 +- jscomp/frontend/ast_attributes.ml | 39 +++++-- jscomp/frontend/ast_payload.ml | 14 +++ jscomp/frontend/ast_payload.mli | 2 + jscomp/frontend/bs_syntaxerr.ml | 8 +- jscomp/frontend/bs_syntaxerr.mli | 1 + jscomp/ml/lambda.ml | 2 +- jscomp/ml/lambda.mli | 2 +- jscomp/ml/matching.ml | 6 +- jscomp/test/variantsMatching.js | 174 +++++++++++++++++++++++++++++- jscomp/test/variantsMatching.res | 105 ++++++++++++++++++ 16 files changed, 401 insertions(+), 35 deletions(-) diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 1020bd37e4..f0bef9f9e4 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -774,13 +774,13 @@ and expression_desc cxt ~(level : int) f x : cxt = ( Js_op.Lit L.tag, match Ast_attributes.process_as_value p.attrs with | None -> E.str p.name - | Some (AsString s) -> E.str s - | Some (AsInt i) -> E.small_int i ) + | Some as_value -> E.as_value as_value ) :: tails in expression_desc cxt ~level f (Object objs) | Caml_block (el, _, tag, Blk_constructor p) -> let not_is_cons = p.name <> Literals.cons in + let as_value = Ast_attributes.process_as_value p.attrs in let objs = let tails = Ext_list.mapi_append el @@ -794,16 +794,19 @@ and expression_desc cxt ~(level : int) f x : cxt = [ (name_symbol, E.str p.name) ] else []) in - if not_is_cons = false && p.num_nonconst = 1 then tails + if (as_value = Some AsUnboxed || not_is_cons = false) && p.num_nonconst = 1 then tails else ( Js_op.Lit L.tag, - match Ast_attributes.process_as_value p.attrs with + match as_value with | None -> E.str p.name - | Some (AsString s) -> E.str s - | Some (AsInt i) -> E.small_int i ) + | Some as_value -> E.as_value as_value ) :: tails in - expression_desc cxt ~level f (Object objs) + let exp = match objs with + | [(_, e)] when as_value = Some AsUnboxed -> e.expression_desc + | _ when as_value = Some AsUnboxed -> assert false (* should not happen *) + | _ -> J.Object objs in + expression_desc cxt ~level f exp | Caml_block ( _, _, @@ -1195,12 +1198,10 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt = let cxt = P.paren_group f 1 (fun _ -> expression ~level:0 cxt f e) in P.space f; P.brace_vgroup f 1 (fun _ -> - let pp_string f (as_value: Lambda.as_value) = - let e = match as_value with - | AsString txt -> E.str txt ~delim:DStarJ - | AsInt i -> E.small_int i in + let pp_as_value f (as_value: Lambda.as_value) = + let e = E.as_value as_value in ignore @@ expression_desc cxt ~level:0 f e.expression_desc in - let cxt = loop_case_clauses cxt f pp_string cc in + let cxt = loop_case_clauses cxt f pp_as_value cc in match def with | None -> cxt | Some def -> diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index 89fb160063..af8bbe981a 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -316,6 +316,13 @@ let small_int i : t = | 248 -> obj_int_tag_literal | i -> int (Int32.of_int i) +let as_value = function + | Lambda.AsString s -> str s ~delim:DStarJ + | AsInt i -> small_int i + | AsNull -> nil + | AsUndefined -> undefined + | AsUnboxed -> assert false (* Should not emit tags for unboxed *) + let array_index ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with | Array (l, _), Number (Int { i; _ }) @@ -762,8 +769,26 @@ let string_equal ?comment (e0 : t) (e1 : t) : t = let is_type_number ?comment (e : t) : t = string_equal ?comment (typeof e) (str "number") -let is_tag (e : t) : t = - { expression_desc = Bin (NotEqEq, typeof e, str "object"); comment=None } +let is_tag ?(has_null_undefined_other=(false, false, false)) (e : t) : t = + let (has_null, has_undefined, has_other) = has_null_undefined_other in + if has_null && (has_undefined = false) && (has_other = false) then (* null *) + { expression_desc = Bin (EqEqEq, e, nil); comment=None } + else if has_null && has_undefined && has_other=false then (* null + undefined *) + { J.expression_desc = Bin + (Or, + { expression_desc = Bin (EqEqEq, e, nil); comment=None }, + { expression_desc = Bin (EqEqEq, e, undefined); comment=None } + ); comment=None } + else if has_null=false && has_undefined && has_other=false then (* undefined *) + { expression_desc = Bin (EqEqEq, e, undefined); comment=None } + else if has_null then (* (null + undefined + other) || (null + other) *) + { J.expression_desc = Bin + (Or, + { expression_desc = Bin (EqEqEq, e, nil); comment=None }, + { expression_desc = Bin (NotEqEq, typeof e, str "object"); comment=None } + ); comment=None } + else (* (undefiled + other) || other *) + { expression_desc = Bin (NotEqEq, typeof e, str "object"); comment=None } let is_type_string ?comment (e : t) : t = string_equal ?comment (typeof e) (str "string") diff --git a/jscomp/core/js_exp_make.mli b/jscomp/core/js_exp_make.mli index 00959c53ae..ec3b2f7b78 100644 --- a/jscomp/core/js_exp_make.mli +++ b/jscomp/core/js_exp_make.mli @@ -185,6 +185,8 @@ val assign_by_exp : t -> t -> t -> t val assign : ?comment:string -> t -> t -> t +val as_value : Lambda.as_value -> t + val triple_equal : ?comment:string -> t -> t -> t (* TODO: reduce [triple_equal] use *) @@ -199,7 +201,8 @@ val eq_null_undefined_boolean : ?comment:string -> t -> t -> t val neq_null_undefined_boolean : ?comment:string -> t -> t -> t val is_type_number : ?comment:string -> t -> t -val is_tag : t -> t + +val is_tag : ?has_null_undefined_other:(bool * bool * bool) -> t -> t val is_type_string : ?comment:string -> t -> t diff --git a/jscomp/core/js_stmt_make.ml b/jscomp/core/js_stmt_make.ml index 88f755f063..8e2587323c 100644 --- a/jscomp/core/js_stmt_make.ml +++ b/jscomp/core/js_stmt_make.ml @@ -138,7 +138,7 @@ let string_switch ?(comment : string option) match switch_case with | AsString s -> if s = txt then Some x.switch_body else None - | AsInt _ -> None) + | AsInt _ | AsNull | AsUnboxed | AsUndefined -> None) with | Some case -> case | None -> ( match default with Some x -> x | None -> assert false) diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 9f3d6a0076..0269b0a165 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -144,6 +144,18 @@ let get_const_name i (sw_names : Lambda.switch_names option) = let get_block_name i (sw_names : Lambda.switch_names option) = match sw_names with None -> None | Some { blocks } -> Some blocks.(i) + +let has_null_undefined_other (sw_names : Lambda.switch_names option) = + let (null, undefined, other) = (ref false, ref false, ref false) in + (match sw_names with + | None -> () + | Some { consts } -> + Ext_array.iter consts (fun x -> match x.as_value with + | Some AsUndefined -> undefined := true + | Some AsNull -> null := true + | _ -> other := true)); + (!null, !undefined, !other) + let no_effects_const = lazy true (* let has_effects_const = lazy false *) @@ -632,7 +644,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) else (* [e] will be used twice *) let dispatch e = - S.if_ (E.is_tag e) + S.if_ (E.is_tag ~has_null_undefined_other:(has_null_undefined_other sw_names) e) (compile_cases cxt e sw_consts sw_num_default get_const_name) (* default still needed, could simplified*) ~else_: @@ -667,9 +679,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) and compile_string_cases cxt switch_exp table default = compile_general_cases (fun _ -> None) - (fun (as_value: Lambda.as_value) -> match as_value with - | AsString s -> E.str s ~delim:DStarJ - | AsInt i -> E.small_int i) + E.as_value E.string_equal cxt (fun ?default ?declaration e clauses -> S.string_switch ?default ?declaration e clauses) diff --git a/jscomp/core/lam_compile_const.ml b/jscomp/core/lam_compile_const.ml index daeeced978..538f209113 100644 --- a/jscomp/core/lam_compile_const.ml +++ b/jscomp/core/lam_compile_const.ml @@ -50,9 +50,7 @@ and translate (x : Lam_constant.t) : J.expression = | Const_int { i; comment = Pt_constructor {cstr_name={name; as_value=None}}} when name <> "[]" -> E.str name | Const_int { i; comment = Pt_constructor {cstr_name={as_value = Some as_value}}} -> - ( match as_value with - | AsString s -> E.str s - | AsInt i -> E.small_int i) + E.as_value as_value | Const_int { i; comment } -> E.int i ?comment:(Lam_constant.string_of_pointer_info comment) | Const_char i -> Js_of_lam_string.const_char i diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index e603ee0c0e..5c9db52ff8 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -334,12 +334,39 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) = | _ -> ()); !st -let process_as_value attrs : Lambda.as_value option = - match iter_process_bs_string_or_int_as attrs with - | None -> None - | Some (Str (s, _)) -> Some (AsString s) - | Some (Int i) -> Some (AsInt i) - +let process_as_value (attrs : t) = + let st : Lambda.as_value option ref = ref None in + Ext_list.iter attrs (fun (({ txt; loc }, payload) as attr) -> + match txt with + | "bs.as" | "as" -> + if !st = None then ( + (match Ast_payload.is_single_string payload with + | None -> () + | Some (s, _dec) -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some (AsString s)); + (match Ast_payload.is_single_int payload with + | None -> () + | Some i -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some (AsInt i)); + (match Ast_payload.is_single_ident payload with + | None -> () + | Some Lident "null" -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some AsNull + | Some Lident "undefined" -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some AsUndefined + | Some Lident "unboxed" -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some AsUnboxed + | Some _ -> Bs_syntaxerr.err loc InvalidVariantAsAnnotation); + if !st = None then Bs_syntaxerr.err loc InvalidVariantAsAnnotation + ) + else Bs_syntaxerr.err loc Duplicated_bs_as + | _ -> ()); + !st let locg = Location.none (* let bs : attr diff --git a/jscomp/frontend/ast_payload.ml b/jscomp/frontend/ast_payload.ml index 5a635b304e..227bd80bbd 100644 --- a/jscomp/frontend/ast_payload.ml +++ b/jscomp/frontend/ast_payload.ml @@ -69,6 +69,20 @@ let is_single_int (x : t) : int option = Some (int_of_string name) | _ -> None +let is_single_ident (x : t) = match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ({ pexp_desc = Pexp_ident lid }, _); + _; + }; + ] -> + Some lid.txt + | _ -> None + + let raw_as_string_exp_exn ~(kind : Js_raw_info.raw_kind) ?is_function (x : t) : Parsetree.expression option = match x with diff --git a/jscomp/frontend/ast_payload.mli b/jscomp/frontend/ast_payload.mli index d3264b94a3..563d444cd6 100644 --- a/jscomp/frontend/ast_payload.mli +++ b/jscomp/frontend/ast_payload.mli @@ -39,6 +39,8 @@ val is_single_string_as_ast : t -> Parsetree.expression option val is_single_int : t -> int option +val is_single_ident : t -> Longident.t option + val raw_as_string_exp_exn : kind:Js_raw_info.raw_kind -> ?is_function:bool ref -> diff --git a/jscomp/frontend/bs_syntaxerr.ml b/jscomp/frontend/bs_syntaxerr.ml index 2065ac2f60..fa0d29bba5 100644 --- a/jscomp/frontend/bs_syntaxerr.ml +++ b/jscomp/frontend/bs_syntaxerr.ml @@ -51,6 +51,7 @@ type error = | Optional_in_uncurried_bs_attribute | Bs_this_simple_pattern | Bs_uncurried_arity_too_large + | InvalidVariantAsAnnotation let pp_error fmt err = Format.pp_print_string fmt @@ -80,7 +81,7 @@ let pp_error fmt err = | Duplicated_bs_deriving -> "duplicate bs.deriving attribute" | Conflict_attributes -> "conflicting attributes " | Expect_string_literal -> "expect string literal " - | Duplicated_bs_as -> "duplicate %@as " + | Duplicated_bs_as -> "duplicate @as " | Expect_int_literal -> "expect int literal " | Expect_int_or_string_or_json_literal -> "expect int, string literal or json literal {json|text here|json} " @@ -96,7 +97,10 @@ let pp_error fmt err = each constructor must have an argument." | Conflict_ffi_attribute str -> "Conflicting attributes: " ^ str | Bs_this_simple_pattern -> - "%@this expect its pattern variable to be simple form") + "%@this expect its pattern variable to be simple form" + | InvalidVariantAsAnnotation -> + "A variant case annotation @as(...) must be a string or integer or null" + ) type exn += Error of Location.t * error diff --git a/jscomp/frontend/bs_syntaxerr.mli b/jscomp/frontend/bs_syntaxerr.mli index 675a34cef6..ef4b35ac84 100644 --- a/jscomp/frontend/bs_syntaxerr.mli +++ b/jscomp/frontend/bs_syntaxerr.mli @@ -51,6 +51,7 @@ type error = | Optional_in_uncurried_bs_attribute | Bs_this_simple_pattern | Bs_uncurried_arity_too_large + | InvalidVariantAsAnnotation val err : Location.t -> error -> 'a diff --git a/jscomp/ml/lambda.ml b/jscomp/ml/lambda.ml index b5369f12cf..f70001f2da 100644 --- a/jscomp/ml/lambda.ml +++ b/jscomp/ml/lambda.ml @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string | AsInt of int +type as_value = AsString of string | AsInt of int | AsNull | AsUndefined | AsUnboxed type cstr_name = {name: string; as_value: as_value option} type tag_info = diff --git a/jscomp/ml/lambda.mli b/jscomp/ml/lambda.mli index 15917dc514..99820c7270 100644 --- a/jscomp/ml/lambda.mli +++ b/jscomp/ml/lambda.mli @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string | AsInt of int +type as_value = AsString of string | AsInt of int | AsNull | AsUndefined | AsUnboxed type cstr_name = {name:string; as_value: as_value option} type tag_info = diff --git a/jscomp/ml/matching.ml b/jscomp/ml/matching.ml index 558c64e335..8925357c3f 100644 --- a/jscomp/ml/matching.ml +++ b/jscomp/ml/matching.ml @@ -1330,7 +1330,11 @@ let make_constr_matching p def ctx = function | ((arg, _mut) :: argl) -> let cstr = pat_as_constr p in let newargs = - if cstr.cstr_inlined <> None then + if cstr.cstr_inlined <> None || + Ext_list.exists cstr.cstr_attributes (function + | ({txt="as"}, PStr [{pstr_desc = Pstr_eval + ({pexp_desc = Pexp_ident {txt= Lident "unboxed"}}, _)}]) -> true + | _ -> false) then (arg, Alias) :: argl else match cstr.cstr_tag with | Cstr_block _ when diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index a27ba04509..f2165363a2 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -177,6 +177,174 @@ var CustomizeTags = { e: CustomizeTags_e }; +function isUndefined(x) { + return x === undefined; +} + +function plus(x, y) { + if (x === undefined) { + return y; + } else if (y === undefined) { + return x; + } else { + return x + y | 0; + } +} + +var MyUndefined = { + $$undefined: undefined, + isUndefined: isUndefined, + plus: plus +}; + +function isNull(x) { + return x === null; +} + +function plus$1(x, y) { + if (x === null) { + return y; + } else if (y === null) { + return x; + } else { + return x + y | 0; + } +} + +var MyNull_null = null; + +var MyNull = { + $$null: MyNull_null, + isNull: isNull, + plus: plus$1 +}; + +function isNull$1(x) { + return x === null; +} + +function isUndefined$1(x) { + return x === undefined; +} + +function plus$2(x, y) { + if (x === null || x === undefined) { + return y; + } else if (y === null || y === undefined) { + return x; + } else { + return x + y | 0; + } +} + +function kind(x) { + if (x === null || x === undefined) { + if (x === null) { + return "null"; + } else { + return "undefined"; + } + } else { + return "present"; + } +} + +var expectSeven = plus$2(3, 4); + +console.log("expect 7:", expectSeven); + +var MyNullable_null = null; + +var MyNullable = { + $$null: MyNullable_null, + $$undefined: undefined, + isNull: isNull$1, + isUndefined: isUndefined$1, + plus: plus$2, + kind: kind, + expectSeven: expectSeven +}; + +function isNull$2(x) { + return x === null; +} + +function isUndefined$2(x) { + return x === undefined; +} + +function isWhyNot(x) { + return x === "WhyNotAnotherOne"; +} + +function plus$3(x, y) { + if (x === null || typeof x !== "object") { + switch (x) { + case null : + case undefined : + return y; + case "WhyNotAnotherOne" : + break; + + } + } else if (!(y === null || typeof y !== "object")) { + return { + x: x.x + y.x, + y: x.y + y.y + }; + } + if (!(y === null || typeof y !== "object")) { + return "WhyNotAnotherOne"; + } + switch (y) { + case null : + case undefined : + return x; + case "WhyNotAnotherOne" : + return "WhyNotAnotherOne"; + + } +} + +function kind$1(x) { + if (!(x === null || typeof x !== "object")) { + return "present"; + } + switch (x) { + case null : + return "null"; + case undefined : + return "undefined"; + case "WhyNotAnotherOne" : + return "whynot"; + + } +} + +var expectSeven$1 = plus$3({ + x: 4, + y: 3 + }, { + x: 3, + y: 4 + }); + +console.log("expect {x:7, y:7}:", expectSeven$1); + +var MyNullableExtended_null = null; + +var MyNullableExtended = { + $$null: MyNullableExtended_null, + $$undefined: undefined, + whynot: "WhyNotAnotherOne", + isNull: isNull$2, + isUndefined: isUndefined$2, + isWhyNot: isWhyNot, + plus: plus$3, + kind: kind$1, + expectSeven: expectSeven$1 +}; + exports.toEnum = toEnum; exports.toString = toString; exports.bar = bar; @@ -188,4 +356,8 @@ exports.showToJs = showToJs; exports.third = third; exports.third2 = third2; exports.CustomizeTags = CustomizeTags; -/* No side effect */ +exports.MyUndefined = MyUndefined; +exports.MyNull = MyNull; +exports.MyNullable = MyNullable; +exports.MyNullableExtended = MyNullableExtended; +/* expectSeven Not a pure module */ diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index 7190b688c5..6e0b76dad5 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -99,3 +99,108 @@ module CustomizeTags = { let d = D(42) let e = E(0) } + +module MyUndefined = { + type t<'a> = | @as(undefined) Undefined | @as(unboxed) Present('a) + // Note: 'a must not have undefined as value + // There can be only one with payload, with 1 argument, to use unboxed + + let undefined = Undefined + + let isUndefined = x => x == Undefined + + let plus = (x, y) => + switch (x, y) { + | (Undefined, _) => y + | (_, Undefined) => x + | (Present(n), Present(m)) => Present(n + m) + } +} + +module MyNull = { + type t<'a> = | @as(null) Null | @as(unboxed) Present('a) + // Note: 'a must not have null as value + // There can be only one with payload, with 1 argument, to use unboxed + + let null = Null + + let isNull = x => x == Null + + let plus = (x, y) => + switch (x, y) { + | (Null, _) => y + | (_, Null) => x + | (Present(n), Present(m)) => Present(n + m) + } +} + +module MyNullable = { + type t<'a> = + | @as(null) Null + | @as(undefined) Undefined + | @as(unboxed) Present('a) + // Note: 'a must not have null or undefined as value + // There can be only one with payload, with 1 argument, to use unboxed + + let null = Null + let undefined = Undefined + + let isNull = x => x == Null + let isUndefined = x => x == Undefined + + let plus = (x, y) => + switch (x, y) { + | (Null | Undefined, _) => y + | (_, Null | Undefined) => x + | (Present(x), Present(y)) => Present(x + y) + } + + let kind = x => + switch x { + | Null => "null" + | Undefined => "undefined" + | Present(_) => "present" + } + + let expectSeven = plus(Present(3), Present(4)) + Js.log2("expect 7:", expectSeven) +} + +module MyNullableExtended = { + type t<'a> = + | @as(null) Null + | @as(undefined) Undefined + | @as(unboxed) Present('a) + | WhyNotAnotherOne + // Note: 'a must be a not have null or something that's not an object as value + // There can be only one with payload, with 1 argument, to use unboxed + + let null = Null + let undefined = Undefined + let whynot = WhyNotAnotherOne + + let isNull = x => x == Null + let isUndefined = x => x == Undefined + let isWhyNot = x => x == WhyNotAnotherOne + + type vector = {x: float, y: float} + + let plus = (x, y) => + switch (x, y) { + | (Null | Undefined, _) => y + | (_, Null | Undefined) => x + | (WhyNotAnotherOne, _) | (_, WhyNotAnotherOne) => WhyNotAnotherOne + | (Present({x: x1, y: y1}), Present({x: x2, y: y2})) => Present({x: x1 +. x2, y: y1 +. y2}) + } + + let kind = x => + switch x { + | Null => "null" + | Undefined => "undefined" + | Present(_) => "present" + | WhyNotAnotherOne => "whynot" + } + + let expectSeven = plus(Present({x: 4., y: 3.}), Present({x: 3., y: 4.})) + Js.log2("expect {x:7, y:7}:", expectSeven) +} From 8d964e9ab35844aaa8972af0ce9478d572ce4861 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Mar 2023 05:50:01 +0100 Subject: [PATCH 08/13] Add tagged unions example from chatgpt. --- jscomp/test/variantsMatching.js | 18 ++++++++++ jscomp/test/variantsMatching.res | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index f2165363a2..e0c44e8c33 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -345,6 +345,23 @@ var MyNullableExtended = { expectSeven: expectSeven$1 }; +function area(shape) { + switch (shape.TAG) { + case "Circle" : + return Math.PI * Math.pow(shape._0.radius, 2); + case "Square" : + return Math.pow(shape._0.sideLength, 2); + case "Rectangle" : + var match = shape._0; + return match.width * match.height; + + } +} + +var TaggedUnions = { + area: area +}; + exports.toEnum = toEnum; exports.toString = toString; exports.bar = bar; @@ -360,4 +377,5 @@ exports.MyUndefined = MyUndefined; exports.MyNull = MyNull; exports.MyNullable = MyNullable; exports.MyNullableExtended = MyNullableExtended; +exports.TaggedUnions = TaggedUnions; /* expectSeven Not a pure module */ diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index 6e0b76dad5..a98b7e61cc 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -204,3 +204,65 @@ module MyNullableExtended = { let expectSeven = plus(Present({x: 4., y: 3.}), Present({x: 3., y: 4.})) Js.log2("expect {x:7, y:7}:", expectSeven) } +module TaggedUnions = { + /* + type Circle = { + kind: 1; // Number literal + radius: number; + }; + + type Square = { + kind: "square"; // String literal + sideLength: number; + }; + + type Rectangle = { + kind: "rectangle"; // String literal + width: number; + height: number; + }; + + type Shape = Circle | Square | Rectangle; + + function area(shape: Shape): number { + switch (shape.kind) { + case 1: // Circle + return Math.PI * shape.radius ** 2; + case "square": // Square + return shape.sideLength ** 2; + case "rectangle": // Rectangle + return shape.width * shape.height; + default: + throw new Error("Invalid shape kind"); + } + } +*/ + type circle = { + kind: string, + radius: float, + } + + type square = { + kind: string, + sideLength: float, + } + + type rectangle = { + kind: string, + width: float, + height: float, + } + + type shape = + | Circle(circle) + | Square(square) + | Rectangle(rectangle) + + let area = (shape: shape): float => { + switch shape { + | Circle({radius}) => Js.Math._PI *. radius ** 2. + | Square({sideLength}) => sideLength ** 2. + | Rectangle({width, height}) => width *. height + } + } +} From b286212b57e73463be8aabca00ec5fcefbc0894c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Mar 2023 05:53:43 +0100 Subject: [PATCH 09/13] Use custom tags. --- jscomp/test/variantsMatching.js | 13 ++++++------- jscomp/test/variantsMatching.res | 22 +++------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index e0c44e8c33..10a17b9d76 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -347,13 +347,12 @@ var MyNullableExtended = { function area(shape) { switch (shape.TAG) { - case "Circle" : - return Math.PI * Math.pow(shape._0.radius, 2); - case "Square" : - return Math.pow(shape._0.sideLength, 2); - case "Rectangle" : - var match = shape._0; - return match.width * match.height; + case 1 : + return Math.PI * Math.pow(shape.radius, 2); + case "square" : + return Math.pow(shape.sideLength, 2); + case "rectangle" : + return shape.width * shape.height; } } diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index a98b7e61cc..173e6eb1e7 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -237,26 +237,10 @@ module TaggedUnions = { } } */ - type circle = { - kind: string, - radius: float, - } - - type square = { - kind: string, - sideLength: float, - } - - type rectangle = { - kind: string, - width: float, - height: float, - } - type shape = - | Circle(circle) - | Square(square) - | Rectangle(rectangle) + | @as(1) Circle({kind: string, radius: float}) + | @as("square") Square({kind: string, sideLength: float}) + | @as("rectangle") Rectangle({kind: string, width: float, height: float}) let area = (shape: shape): float => { switch shape { From 4b9d87e9f165f54650df9adfaccfb393c45ba8e1 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Mar 2023 06:09:01 +0100 Subject: [PATCH 10/13] Remove unused set_tag from compiler internals. --- jscomp/core/j.ml | 1 - jscomp/core/js_analyzer.ml | 1 - jscomp/others/belt_internals.mli | 2 -- jscomp/runtime/bs_stdlib_mini.mli | 2 -- jscomp/stdlib-406/camlinternalLazy.ml | 1 - jscomp/stdlib-406/obj.mli | 7 +------ 6 files changed, 1 insertion(+), 13 deletions(-) diff --git a/jscomp/core/j.ml b/jscomp/core/j.ml index 34692371b6..65d5df017e 100644 --- a/jscomp/core/j.ml +++ b/jscomp/core/j.ml @@ -161,7 +161,6 @@ and expression_desc = you have to use [E.tag] in a safe way *) | Caml_block_tag of expression - (* | Caml_block_set_tag of expression * expression *) (* | Caml_block_set_length of expression * expression *) (* It will just fetch tag, to make it safe, when creating it, we need apply "|0", we don't do it in the diff --git a/jscomp/core/js_analyzer.ml b/jscomp/core/js_analyzer.ml index cd4efa8915..a645302eb9 100644 --- a/jscomp/core/js_analyzer.ml +++ b/jscomp/core/js_analyzer.ml @@ -104,7 +104,6 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) = | Length (e, _) | Caml_block_tag e | Typeof e -> no_side_effect e | Bin (op, a, b) -> op <> Eq && no_side_effect a && no_side_effect b | Js_not _ | Cond _ | FlatCall _ | Call _ | New _ | Raw_js_code _ - (* | Caml_block_set_tag _ *) (* actually true? *) -> false | Await _ -> false diff --git a/jscomp/others/belt_internals.mli b/jscomp/others/belt_internals.mli index c79167851f..402d46011c 100644 --- a/jscomp/others/belt_internals.mli +++ b/jscomp/others/belt_internals.mli @@ -58,8 +58,6 @@ module Obj : sig external field : t -> int -> t = "%obj_field" external set_field : t -> int -> t -> unit = "%obj_set_field" external tag : t -> int = "?obj_tag" - (* The compiler ensures (|0) operation *) - external set_tag : t -> int -> unit = "TAG" [@@bs.set] external repr : 'a -> t = "%identity" external obj : t -> 'a = "%identity" external magic : 'a -> 'b = "%identity" diff --git a/jscomp/runtime/bs_stdlib_mini.mli b/jscomp/runtime/bs_stdlib_mini.mli index c79167851f..402d46011c 100644 --- a/jscomp/runtime/bs_stdlib_mini.mli +++ b/jscomp/runtime/bs_stdlib_mini.mli @@ -58,8 +58,6 @@ module Obj : sig external field : t -> int -> t = "%obj_field" external set_field : t -> int -> t -> unit = "%obj_set_field" external tag : t -> int = "?obj_tag" - (* The compiler ensures (|0) operation *) - external set_tag : t -> int -> unit = "TAG" [@@bs.set] external repr : 'a -> t = "%identity" external obj : t -> 'a = "%identity" external magic : 'a -> 'b = "%identity" diff --git a/jscomp/stdlib-406/camlinternalLazy.ml b/jscomp/stdlib-406/camlinternalLazy.ml index 5a3efc6c41..2f2f4545b1 100644 --- a/jscomp/stdlib-406/camlinternalLazy.ml +++ b/jscomp/stdlib-406/camlinternalLazy.ml @@ -46,7 +46,6 @@ exception Undefined let%private forward_with_closure (type a ) (blk : a t) (closure : unit -> a [@bs]) : a = let result = closure () [@bs] in - (* do set_field BEFORE set_tag *) blk.value <- result; blk.tag<- true; result diff --git a/jscomp/stdlib-406/obj.mli b/jscomp/stdlib-406/obj.mli index 0725df2e19..429a38cea4 100644 --- a/jscomp/stdlib-406/obj.mli +++ b/jscomp/stdlib-406/obj.mli @@ -42,12 +42,7 @@ external field : t -> int -> t = "%obj_field" [set_field] MUST NOT be called on immutable blocks. (Blocks allocated in C stubs, or with [new_block] below, are always considered mutable.) - - The same goes for [set_double_field] and [set_tag]. However, for - [set_tag], in the case of immutable blocks where the middle-end optimizers - never see code that discriminates on their tag (for example records), the - operation should be safe. Such uses are nonetheless discouraged. - + For experts only: [set_field] et al can be made safe by first wrapping the block in {!Sys.opaque_identity}, so any information about its contents will not From 273c4f4e4743a96a43dd64db102f50907fdf9d6e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Mar 2023 11:58:19 +0100 Subject: [PATCH 11/13] Add support for @tag(...) to customize the property used for the tag. --- jscomp/core/j.ml | 11 +- jscomp/core/js_analyzer.ml | 2 +- jscomp/core/js_dump.ml | 14 +- jscomp/core/js_exp_make.ml | 4 +- jscomp/core/js_exp_make.mli | 2 +- jscomp/core/js_fold.ml | 2 +- jscomp/core/js_record_fold.ml | 2 +- jscomp/core/js_record_iter.ml | 2 +- jscomp/core/js_record_map.ml | 4 +- jscomp/core/lam_compile.ml | 20 +- jscomp/core/lam_print.ml | 2 +- jscomp/core/matching_polyfill.ml | 7 +- jscomp/frontend/ast_attributes.ml | 17 + jscomp/frontend/ast_attributes.mli | 4 +- jscomp/frontend/bs_syntaxerr.ml | 3 + jscomp/frontend/bs_syntaxerr.mli | 1 + jscomp/ml/datarepr.ml | 2 +- jscomp/ml/lambda.ml | 7 +- jscomp/ml/lambda.mli | 4 +- jscomp/ml/translcore.ml | 8 +- jscomp/ml/typedecl.ml | 7 +- jscomp/ml/types.ml | 2 +- jscomp/ml/types.mli | 2 +- jscomp/test/ast_abstract_test.js | 153 - jscomp/test/ast_js_mapper_poly_test.js | 272 - jscomp/test/ast_mapper_defensive_test.js | 96 - jscomp/test/flow_parser_reg_test.js | 5939 +++++++++--------- jscomp/test/gpr_4519_test.js | 8 +- jscomp/test/inline_record_test.js | 8 +- jscomp/test/large_record_duplication_test.js | 2 +- jscomp/test/lexer_test.js | 219 - jscomp/test/mario_game.js | 248 +- jscomp/test/method_chain.js | 9 - jscomp/test/ocaml_re_test.js | 940 +-- jscomp/test/rbset.js | 198 +- jscomp/test/record_extension_test.js | 2 +- jscomp/test/ticker.js | 2 +- jscomp/test/variantsMatching.js | 32 +- jscomp/test/variantsMatching.res | 18 +- 39 files changed, 3808 insertions(+), 4467 deletions(-) delete mode 100644 jscomp/test/ast_js_mapper_poly_test.js delete mode 100644 jscomp/test/ast_mapper_defensive_test.js delete mode 100644 jscomp/test/lexer_test.js delete mode 100644 jscomp/test/method_chain.js diff --git a/jscomp/core/j.ml b/jscomp/core/j.ml index 65d5df017e..815779fa2f 100644 --- a/jscomp/core/j.ml +++ b/jscomp/core/j.ml @@ -151,16 +151,7 @@ and expression_desc = (* | Caml_uninitialized_obj of expression * expression *) (* [tag] and [size] tailed for [Obj.new_block] *) - (* For setter, it still return the value of expression, - we can not use - {[ - type 'a access = Get | Set of 'a - ]} - in another module, since it will break our code generator - [Caml_block_tag] can return [undefined], - you have to use [E.tag] in a safe way - *) - | Caml_block_tag of expression + | Caml_block_tag of expression * string (* e.tag *) (* | Caml_block_set_length of expression * expression *) (* It will just fetch tag, to make it safe, when creating it, we need apply "|0", we don't do it in the diff --git a/jscomp/core/js_analyzer.ml b/jscomp/core/js_analyzer.ml index a645302eb9..a4ca28e105 100644 --- a/jscomp/core/js_analyzer.ml +++ b/jscomp/core/js_analyzer.ml @@ -101,7 +101,7 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) = | Optional_block (x, _) -> no_side_effect x | Object kvs -> Ext_list.for_all_snd kvs no_side_effect | String_append (a, b) | Seq (a, b) -> no_side_effect a && no_side_effect b - | Length (e, _) | Caml_block_tag e | Typeof e -> no_side_effect e + | Length (e, _) | Caml_block_tag (e, _) | Typeof e -> no_side_effect e | Bin (op, a, b) -> op <> Eq && no_side_effect a && no_side_effect b | Js_not _ | Cond _ | FlatCall _ | Call _ | New _ | Raw_js_code _ (* actually true? *) -> diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index f0bef9f9e4..afb85db1b3 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -762,6 +762,9 @@ and expression_desc cxt ~(level : int) f x : cxt = | Lit n -> Ext_list.mem_string p.optional_labels n | Symbol_name -> false in + let tag_name = match Ast_attributes.process_tag_name p.attrs with + | None -> L.tag + | Some s -> s in let tails = match p.optional_labels with | [] -> tails @@ -771,7 +774,7 @@ and expression_desc cxt ~(level : int) f x : cxt = | Undefined when is_optional f -> None | _ -> Some (f, x)) in - ( Js_op.Lit L.tag, + ( Js_op.Lit tag_name, (* TAG:xx for inline records *) match Ast_attributes.process_as_value p.attrs with | None -> E.str p.name | Some as_value -> E.as_value as_value ) @@ -781,6 +784,9 @@ and expression_desc cxt ~(level : int) f x : cxt = | Caml_block (el, _, tag, Blk_constructor p) -> let not_is_cons = p.name <> Literals.cons in let as_value = Ast_attributes.process_as_value p.attrs in + let tag_name = match Ast_attributes.process_tag_name p.attrs with + | None -> L.tag + | Some s -> s in let objs = let tails = Ext_list.mapi_append el @@ -796,7 +802,7 @@ and expression_desc cxt ~(level : int) f x : cxt = in if (as_value = Some AsUnboxed || not_is_cons = false) && p.num_nonconst = 1 then tails else - ( Js_op.Lit L.tag, + ( Js_op.Lit tag_name, (* TAG:xx *) match as_value with | None -> E.str p.name | Some as_value -> E.as_value as_value ) @@ -816,11 +822,11 @@ and expression_desc cxt ~(level : int) f x : cxt = assert false | Caml_block (el, mutable_flag, _tag, Blk_tuple) -> expression_desc cxt ~level f (Array (el, mutable_flag)) - | Caml_block_tag e -> + | Caml_block_tag (e, tag) -> P.group f 1 (fun _ -> let cxt = expression ~level:15 cxt f e in P.string f L.dot; - P.string f L.tag; + P.string f tag; cxt) | Array_index (e, p) -> P.cond_paren_group f (level > 15) 1 (fun _ -> diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index af8bbe981a..ce47d46c02 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -800,8 +800,8 @@ let is_type_object (e : t) : t = string_equal (typeof e) (str "object") call plain [dot] *) -let tag ?comment e : t = - { expression_desc = Caml_block_tag e; comment } +let tag ?comment ?(name=Js_dump_lit.tag) e : t = + { expression_desc = Caml_block_tag (e, name); comment } (* according to the compiler, [Btype.hash_variant], it's reduced to 31 bits for hash diff --git a/jscomp/core/js_exp_make.mli b/jscomp/core/js_exp_make.mli index ec3b2f7b78..565b03d27b 100644 --- a/jscomp/core/js_exp_make.mli +++ b/jscomp/core/js_exp_make.mli @@ -307,7 +307,7 @@ val unit : t val undefined : t -val tag : ?comment:string -> J.expression -> t +val tag : ?comment:string -> ?name:string -> J.expression -> t (** Note that this is coupled with how we encode block, if we use the `Object.defineProperty(..)` since the array already hold the length, diff --git a/jscomp/core/js_fold.ml b/jscomp/core/js_fold.ml index b29368f8f9..42d8410ba6 100644 --- a/jscomp/core/js_fold.ml +++ b/jscomp/core/js_fold.ml @@ -162,7 +162,7 @@ class fold = let _self = list (fun _self -> _self#expression) _self _x0 in let _self = _self#expression _x2 in _self - | Caml_block_tag _x0 -> + | Caml_block_tag (_x0, _tag) -> let _self = _self#expression _x0 in _self | Number _ -> _self diff --git a/jscomp/core/js_record_fold.ml b/jscomp/core/js_record_fold.ml index 8ed0ab31eb..04b4f546ba 100644 --- a/jscomp/core/js_record_fold.ml +++ b/jscomp/core/js_record_fold.ml @@ -168,7 +168,7 @@ let expression_desc : 'a. ('a, expression_desc) fn = let st = list _self.expression _self st _x0 in let st = _self.expression _self st _x2 in st - | Caml_block_tag _x0 -> + | Caml_block_tag (_x0, _tag) -> let st = _self.expression _self st _x0 in st | Number _ -> st diff --git a/jscomp/core/js_record_iter.ml b/jscomp/core/js_record_iter.ml index cd93ddf495..e7a0cdfddd 100644 --- a/jscomp/core/js_record_iter.ml +++ b/jscomp/core/js_record_iter.ml @@ -128,7 +128,7 @@ let expression_desc : expression_desc fn = | Caml_block (_x0, _x1, _x2, _x3) -> list _self.expression _self _x0; _self.expression _self _x2 - | Caml_block_tag _x0 -> _self.expression _self _x0 + | Caml_block_tag (_x0, _tag) -> _self.expression _self _x0 | Number _ -> () | Object _x0 -> property_map _self _x0 | Undefined -> () diff --git a/jscomp/core/js_record_map.ml b/jscomp/core/js_record_map.ml index a4d3335b63..85a8ee2e5c 100644 --- a/jscomp/core/js_record_map.ml +++ b/jscomp/core/js_record_map.ml @@ -166,9 +166,9 @@ let expression_desc : expression_desc fn = let _x0 = list _self.expression _self _x0 in let _x2 = _self.expression _self _x2 in Caml_block (_x0, _x1, _x2, _x3) - | Caml_block_tag _x0 -> + | Caml_block_tag (_x0, tag) -> let _x0 = _self.expression _self _x0 in - Caml_block_tag _x0 + Caml_block_tag (_x0, tag) | Number _ as v -> v | Object _x0 -> let _x0 = property_map _self _x0 in diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 0269b0a165..189bd1559b 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -141,9 +141,17 @@ let default_action ~saturated failaction = let get_const_name i (sw_names : Lambda.switch_names option) = match sw_names with None -> None | Some { consts } -> Some consts.(i) -let get_block_name i (sw_names : Lambda.switch_names option) = +let get_block i (sw_names : Lambda.switch_names option) = match sw_names with None -> None | Some { blocks } -> Some blocks.(i) +let get_tag_name (sw_names : Lambda.switch_names option) = + match sw_names with + | None -> Js_dump_lit.tag + | Some { blocks } -> + (match Array.find_opt (fun {Lambda.tag_name} -> tag_name <> None) blocks with + | Some {tag_name = Some s} -> s + | _ -> Js_dump_lit.tag + ) let has_null_undefined_other (sw_names : Lambda.switch_names option) = let (null, undefined, other) = (ref false, ref false, ref false) in @@ -628,7 +636,11 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) default_action ~saturated:sw_blocks_full sw_failaction in let get_const_name i = get_const_name i sw_names in - let get_block_name i = get_block_name i sw_names in + let get_block i = get_block i sw_names in + let get_block_name i = match get_block i with + | None -> None + | Some {cstr_name} -> Some cstr_name in + let tag_name = get_tag_name sw_names in let compile_whole (cxt : Lam_compile_context.t) = match compile_lambda { cxt with continuation = NeedValue Not_tail } switch_arg @@ -638,7 +650,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) block @ if sw_consts_full && sw_consts = [] then - compile_cases cxt (E.tag e) sw_blocks sw_blocks_default get_block_name + compile_cases cxt (E.tag ~name:tag_name e) sw_blocks sw_blocks_default get_block_name else if sw_blocks_full && sw_blocks = [] then compile_cases cxt e sw_consts sw_num_default get_const_name else @@ -648,7 +660,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch) (compile_cases cxt e sw_consts sw_num_default get_const_name) (* default still needed, could simplified*) ~else_: - (compile_cases cxt (E.tag e) sw_blocks sw_blocks_default + (compile_cases cxt (E.tag ~name:tag_name e) sw_blocks sw_blocks_default get_block_name) in match e.expression_desc with diff --git a/jscomp/core/lam_print.ml b/jscomp/core/lam_print.ml index 9860bb3788..16200fd72c 100644 --- a/jscomp/core/lam_print.ml +++ b/jscomp/core/lam_print.ml @@ -320,7 +320,7 @@ let lambda ppf v = (fun (n, l) -> if !spc then fprintf ppf "@ " else spc := true; fprintf ppf "@[case tag %i %S:@ %a@]" n - (match sw.sw_names with None -> "" | Some x -> x.blocks.(n).name) + (match sw.sw_names with None -> "" | Some x -> x.blocks.(n).cstr_name.name) lam l) sw.sw_blocks; match sw.sw_failaction with diff --git a/jscomp/core/matching_polyfill.ml b/jscomp/core/matching_polyfill.ml index 3b04c59aa2..2b6cc9e6bb 100644 --- a/jscomp/core/matching_polyfill.ml +++ b/jscomp/core/matching_polyfill.ml @@ -30,11 +30,15 @@ let names_from_construct_pattern (pat : Typedtree.pattern) = let get_cstr_name (cstr: Types.constructor_declaration) = { Lambda.name = Ident.name cstr.cd_id; as_value = Ast_attributes.process_as_value cstr.cd_attributes } in + let get_tag_name (cstr: Types.constructor_declaration) = + Ast_attributes.process_tag_name cstr.cd_attributes in + let get_block cstr : Lambda.block = + {cstr_name = get_cstr_name cstr; tag_name = get_tag_name cstr} in let consts, blocks = Ext_list.fold_left cstrs ([], []) (fun (consts, blocks) cstr -> if is_nullary_variant cstr.cd_args then (get_cstr_name cstr :: consts, blocks) - else (consts, get_cstr_name cstr :: blocks)) + else (consts, get_block cstr :: blocks)) in Some { @@ -48,7 +52,6 @@ let names_from_construct_pattern (pat : Typedtree.pattern) = | { type_kind = Type_abstract; type_manifest = Some t; _ } -> ( match (Ctype.unalias t).desc with | Tconstr (pathn, _, _) -> - (* Format.eprintf "XXX path%d:%s path%d:%s@." n (Path.name path) (n+1) (Path.name pathn); *) resolve_path (n + 1) pathn | _ -> None) | { type_kind = Type_abstract; type_manifest = None; _ } -> None diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index 5c9db52ff8..c73f413df3 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -368,6 +368,23 @@ let process_as_value (attrs : t) = | _ -> ()); !st +let process_tag_name (attrs : t) = + let st = ref None in + Ext_list.iter attrs (fun (({ txt; loc }, payload) as attr) -> + match txt with + | "tag" -> + if !st = None then ( + (match Ast_payload.is_single_string payload with + | None -> () + | Some (s, _dec) -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some s); + if !st = None then Bs_syntaxerr.err loc InvalidVariantTagAnnotation + ) + else Bs_syntaxerr.err loc Duplicated_bs_as + | _ -> ()); + !st + let locg = Location.none (* let bs : attr = {txt = "bs" ; loc = locg}, Ast_payload.empty *) diff --git a/jscomp/frontend/ast_attributes.mli b/jscomp/frontend/ast_attributes.mli index ed9ebfa34b..c495fff9a9 100644 --- a/jscomp/frontend/ast_attributes.mli +++ b/jscomp/frontend/ast_attributes.mli @@ -92,4 +92,6 @@ val rs_externals : t -> string list -> bool val process_send_pipe : t -> (Parsetree.core_type * t) option -val process_as_value : t -> Lambda.as_value option \ No newline at end of file +val process_as_value : t -> Lambda.as_value option + +val process_tag_name : t -> string option \ No newline at end of file diff --git a/jscomp/frontend/bs_syntaxerr.ml b/jscomp/frontend/bs_syntaxerr.ml index fa0d29bba5..35cb332ad2 100644 --- a/jscomp/frontend/bs_syntaxerr.ml +++ b/jscomp/frontend/bs_syntaxerr.ml @@ -52,6 +52,7 @@ type error = | Bs_this_simple_pattern | Bs_uncurried_arity_too_large | InvalidVariantAsAnnotation + | InvalidVariantTagAnnotation let pp_error fmt err = Format.pp_print_string fmt @@ -100,6 +101,8 @@ let pp_error fmt err = "%@this expect its pattern variable to be simple form" | InvalidVariantAsAnnotation -> "A variant case annotation @as(...) must be a string or integer or null" + | InvalidVariantTagAnnotation -> + "A variant tag annotation @tag(...) must be a string" ) type exn += Error of Location.t * error diff --git a/jscomp/frontend/bs_syntaxerr.mli b/jscomp/frontend/bs_syntaxerr.mli index ef4b35ac84..15c39baee0 100644 --- a/jscomp/frontend/bs_syntaxerr.mli +++ b/jscomp/frontend/bs_syntaxerr.mli @@ -52,6 +52,7 @@ type error = | Bs_this_simple_pattern | Bs_uncurried_arity_too_large | InvalidVariantAsAnnotation + | InvalidVariantTagAnnotation val err : Location.t -> error -> 'a diff --git a/jscomp/ml/datarepr.ml b/jscomp/ml/datarepr.ml index 105462df08..8412621f5c 100644 --- a/jscomp/ml/datarepr.ml +++ b/jscomp/ml/datarepr.ml @@ -142,7 +142,7 @@ let constructor_descrs ty_path decl cstrs = let representation = if decl.type_unboxed.unboxed then Record_unboxed true - else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts; optional_labels} + else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts; optional_labels; attrs = cd_attributes} in constructor_args decl.type_private cd_args cd_res (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation diff --git a/jscomp/ml/lambda.ml b/jscomp/ml/lambda.ml index f70001f2da..21de5f6e6d 100644 --- a/jscomp/ml/lambda.ml +++ b/jscomp/ml/lambda.ml @@ -99,9 +99,9 @@ let blk_record_ext = ref (fun fields mutable_flag -> Blk_record_ext {fields = all_labels_info; mutable_flag } ) -let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag mutable_flag -> +let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag ~attrs mutable_flag -> let fields = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in - Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs = []} + Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs } ) let ref_tag_info : tag_info = @@ -273,7 +273,8 @@ type function_attribute = { return_unit : bool; async : bool; } -type switch_names = {consts: cstr_name array; blocks: cstr_name array} +type block = {cstr_name: cstr_name; tag_name: string option} +type switch_names = {consts: cstr_name array; blocks: block array} type lambda = Lvar of Ident.t diff --git a/jscomp/ml/lambda.mli b/jscomp/ml/lambda.mli index 99820c7270..608e93d455 100644 --- a/jscomp/ml/lambda.mli +++ b/jscomp/ml/lambda.mli @@ -90,6 +90,7 @@ val blk_record_inlined : int -> string list -> tag:int -> + attrs:Parsetree.attributes -> mutable_flag -> tag_info ) ref @@ -275,7 +276,8 @@ type function_attribute = { async : bool; } -type switch_names = {consts: cstr_name array; blocks: cstr_name array} +type block = {cstr_name: cstr_name; tag_name: string option} +type switch_names = {consts: cstr_name array; blocks: block array} type lambda = Lvar of Ident.t diff --git a/jscomp/ml/translcore.ml b/jscomp/ml/translcore.ml index ad0c8402d9..470c1008e4 100644 --- a/jscomp/ml/translcore.ml +++ b/jscomp/ml/translcore.ml @@ -1157,10 +1157,10 @@ and transl_record loc env fields repres opt_init_expr = | Record_optional_labels _ -> Lconst (Const_block (!Lambda.blk_record fields mut Record_optional, cl)) - | Record_inlined { tag; name; num_nonconsts; optional_labels } -> + | Record_inlined { tag; name; num_nonconsts; optional_labels; attrs } -> Lconst (Const_block - ( !Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag + ( !Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag ~attrs mut, cl )) | Record_unboxed _ -> @@ -1179,10 +1179,10 @@ and transl_record loc env fields repres opt_init_expr = ll, loc ) | Record_float_unused -> assert false - | Record_inlined { tag; name; num_nonconsts; optional_labels } -> + | Record_inlined { tag; name; num_nonconsts; optional_labels; attrs } -> Lprim ( Pmakeblock - (!Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag + (!Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag ~attrs mut), ll, loc ) diff --git a/jscomp/ml/typedecl.ml b/jscomp/ml/typedecl.ml index 36097256f8..c1a1e825c6 100644 --- a/jscomp/ml/typedecl.ml +++ b/jscomp/ml/typedecl.ml @@ -379,6 +379,9 @@ let transl_declaration env sdecl id = raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); all_constrs := StringSet.add name !all_constrs) scstrs; + let copy_tag_attr_from_decl attr = + let tag_attr = Ext_list.filter sdecl.ptype_attributes (fun ({txt}, _) -> txt = "tag") in + if tag_attr = [] then attr else tag_attr @ attr in let make_cstr scstr = let name = Ident.create scstr.pcd_name.txt in let targs, tret_type, args, ret_type, _cstr_params = @@ -391,14 +394,14 @@ let transl_declaration env sdecl id = cd_args = targs; cd_res = tret_type; cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } + cd_attributes = scstr.pcd_attributes |> copy_tag_attr_from_decl } in let cstr = { Types.cd_id = name; cd_args = args; cd_res = ret_type; cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } + cd_attributes = scstr.pcd_attributes |> copy_tag_attr_from_decl } in tcstr, cstr in diff --git a/jscomp/ml/types.ml b/jscomp/ml/types.ml index 1dea0bec6d..0c94b4bc67 100644 --- a/jscomp/ml/types.ml +++ b/jscomp/ml/types.ml @@ -154,7 +154,7 @@ and record_representation = | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) - { tag : int ; name : string; num_nonconsts : int; optional_labels : string list} + { tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes} | Record_extension (* Inlined record under extension *) | Record_optional_labels of string list (* List of optional labels *) diff --git a/jscomp/ml/types.mli b/jscomp/ml/types.mli index e87361929d..eacf0b7d2b 100644 --- a/jscomp/ml/types.mli +++ b/jscomp/ml/types.mli @@ -301,7 +301,7 @@ and record_representation = | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) - { tag : int ; name : string; num_nonconsts : int; optional_labels : string list} + { tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes } | Record_extension (* Inlined record under extension *) | Record_optional_labels of string list (* List of optional labels *) diff --git a/jscomp/test/ast_abstract_test.js b/jscomp/test/ast_abstract_test.js index a2ec672687..e3410cbc31 100644 --- a/jscomp/test/ast_abstract_test.js +++ b/jscomp/test/ast_abstract_test.js @@ -76,144 +76,12 @@ idx("b"); idx("c"); -var jsMapperConstantArray = [ - 0, - 3, - 4 -]; - -function aToJs(param) { - return jsMapperConstantArray[param]; -} - -function aFromJs(param) { - return Js_mapperRt.fromIntAssert(3, jsMapperConstantArray, param); -} - -function id(x) { - eq("File \"ast_abstract_test.ml\", line 49, characters 8-15", aFromJs(aToJs(x)), x); -} - -var a0 = aToJs("A"); - -var a1 = aToJs("B"); - -id("A"); - -id("B"); - -id("C"); - -function bToJs(param) { - return param + 0 | 0; -} - -function bFromJs(param) { - if (!(param <= 3 && 0 <= param)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 1, - -1 - ], - Error: new Error() - }; - } - return param - 0 | 0; -} - -function idb(v) { - eq("File \"ast_abstract_test.ml\", line 71, characters 5-12", bFromJs(v + 0 | 0), v); -} - -idb("D0"); - -idb("D1"); - -idb("D2"); - -idb("D3"); - -function cToJs(param) { - return param + 3 | 0; -} - -function cFromJs(param) { - if (!(param <= 6 && 3 <= param)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 1, - -1 - ], - Error: new Error() - }; - } - return param - 3 | 0; -} - -function idc(v) { - eq("File \"ast_abstract_test.ml\", line 83, characters 15-22", cFromJs(v + 3 | 0), v); -} - -idc("D0"); - -idc("D1"); - -idc("D2"); - -idc("D3"); - -function hToJs(param) { - return param + 0 | 0; -} - -function hFromJs(param) { - if (!(param <= 1 && 0 <= param)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 1, - -1 - ], - Error: new Error() - }; - } - return param - 0 | 0; -} - -function zToJs(param) { - return param + 0 | 0; -} - -function zFromJs(param) { - if (param <= 2 && 0 <= param) { - return param - 0 | 0; - } - -} - Mt.from_pair_suites("Ast_abstract_test", suites.contents); var x0 = "a"; var x1 = "b"; -var b0 = 0; - -var b1 = 1; - -var c0 = 3; - -var jsMapperEraseType = "JsMapperEraseType"; - -var b = "B"; - -var zXx = "ZXx"; - exports.suites = suites; exports.test_id = test_id; exports.eq = eq; @@ -226,25 +94,4 @@ exports.xFromJs = xFromJs; exports.idx = idx; exports.x0 = x0; exports.x1 = x1; -exports.aToJs = aToJs; -exports.aFromJs = aFromJs; -exports.id = id; -exports.a0 = a0; -exports.a1 = a1; -exports.bToJs = bToJs; -exports.bFromJs = bFromJs; -exports.b0 = b0; -exports.b1 = b1; -exports.idb = idb; -exports.cToJs = cToJs; -exports.cFromJs = cFromJs; -exports.c0 = c0; -exports.idc = idc; -exports.jsMapperEraseType = jsMapperEraseType; -exports.b = b; -exports.hToJs = hToJs; -exports.hFromJs = hFromJs; -exports.zXx = zXx; -exports.zToJs = zToJs; -exports.zFromJs = zFromJs; /* Not a pure module */ diff --git a/jscomp/test/ast_js_mapper_poly_test.js b/jscomp/test/ast_js_mapper_poly_test.js deleted file mode 100644 index 62c5f76346..0000000000 --- a/jscomp/test/ast_js_mapper_poly_test.js +++ /dev/null @@ -1,272 +0,0 @@ -'use strict'; - -var Mt = require("./mt.js"); -var $$Array = require("../../lib/js/array.js"); -var Js_mapperRt = require("../../lib/js/js_mapperRt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: y - }; - }) - ], - tl: suites.contents - }; -} - -var _map = {"D":"D","C":"C","f":"x"}; - -var _revMap = {"D":"D","C":"C","x":"f"}; - -function uToJs(param) { - return _map[param]; -} - -function uFromJs(param) { - return _revMap[param]; -} - -function eqU(x, y) { - return x === y; -} - -function eqUOpt(x, y) { - if (x !== undefined) { - if (y !== undefined) { - return x === y; - } else { - return false; - } - } else { - return y === undefined; - } -} - -eq("File \"ast_js_mapper_poly_test.ml\", line 25, characters 5-12", eqUOpt(uFromJs("x"), "f"), true); - -eq("File \"ast_js_mapper_poly_test.ml\", line 26, characters 5-12", eqUOpt(uFromJs("D"), "D"), true); - -eq("File \"ast_js_mapper_poly_test.ml\", line 27, characters 5-12", eqUOpt(uFromJs("C"), "C"), true); - -eq("File \"ast_js_mapper_poly_test.ml\", line 28, characters 5-12", eqUOpt(uFromJs("f"), undefined), true); - -eq("File \"ast_js_mapper_poly_test.ml\", line 29, characters 5-12", $$Array.map(uToJs, [ - "D", - "C", - "f" - ]), [ - "D", - "C", - "x" - ]); - -var jsMapperConstantArray = [ - 0, - 3, - 4, - 5 -]; - -function vToJs(param) { - return jsMapperConstantArray[param]; -} - -function vFromJs(param) { - return Js_mapperRt.fromInt(4, jsMapperConstantArray, param); -} - -function eqV(x, y) { - return x === y; -} - -function eqVOpt(x, y) { - if (x !== undefined) { - if (y !== undefined) { - return x === y; - } else { - return false; - } - } else { - return y === undefined; - } -} - -function s(param) { - switch (param) { - case "A0" : - return "A0"; - case "A1" : - return "A1"; - case "A2" : - return "A2"; - case "A3" : - return "A3"; - - } -} - -eq("File \"ast_js_mapper_poly_test.ml\", line 54, characters 5-12", $$Array.map(vToJs, [ - "A0", - "A1", - "A2", - "A3" - ]), [ - 0, - 3, - 4, - 5 - ]); - -eq("File \"ast_js_mapper_poly_test.ml\", line 55, characters 5-12", $$Array.map(vFromJs, [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ]), [ - "A0", - undefined, - undefined, - "A1", - "A2", - "A3", - undefined - ]); - -function v1ToJs(param) { - return param + 0 | 0; -} - -function v1FromJs(param) { - if (param <= 5 && 0 <= param) { - return param - 0 | 0; - } - -} - -eq("File \"ast_js_mapper_poly_test.ml\", line 68, characters 5-12", $$Array.map(v1ToJs, [ - "B0", - "B1", - "B2", - "B3", - "B4", - "B5" - ]), [ - 0, - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"ast_js_mapper_poly_test.ml\", line 69, characters 5-12", $$Array.map(v1FromJs, [ - -1, - 0, - 1, - 2, - 3, - 4, - 5, - 6 - ]), [ - undefined, - "B0", - "B1", - "B2", - "B3", - "B4", - "B5", - undefined - ]); - -function v2ToJs(param) { - return param + 2 | 0; -} - -function v2FromJs(param) { - if (param <= 7 && 2 <= param) { - return param - 2 | 0; - } - -} - -eq("File \"ast_js_mapper_poly_test.ml\", line 86, characters 5-12", $$Array.map(v2ToJs, [ - "C0", - "C1", - "C2", - "C3", - "C4", - "C5" - ]), [ - 2, - 3, - 4, - 5, - 6, - 7 - ]); - -eq("File \"ast_js_mapper_poly_test.ml\", line 89, characters 5-12", $$Array.map(v2FromJs, [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ]), $$Array.append($$Array.append([ - undefined, - undefined - ], $$Array.map((function (x) { - return x; - }), [ - "C0", - "C1", - "C2", - "C3", - "C4", - "C5" - ])), [undefined])); - -Mt.from_pair_suites("Ast_js_mapper_poly_test", suites.contents); - -var $plus$great = $$Array.append; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.uToJs = uToJs; -exports.uFromJs = uFromJs; -exports.eqU = eqU; -exports.eqUOpt = eqUOpt; -exports.vToJs = vToJs; -exports.vFromJs = vFromJs; -exports.eqV = eqV; -exports.eqVOpt = eqVOpt; -exports.s = s; -exports.v1ToJs = v1ToJs; -exports.v1FromJs = v1FromJs; -exports.v2ToJs = v2ToJs; -exports.v2FromJs = v2FromJs; -exports.$plus$great = $plus$great; -/* Not a pure module */ diff --git a/jscomp/test/ast_mapper_defensive_test.js b/jscomp/test/ast_mapper_defensive_test.js deleted file mode 100644 index c742f9bf32..0000000000 --- a/jscomp/test/ast_mapper_defensive_test.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict'; - -var Mt = require("./mt.js"); -var Js_mapperRt = require("../../lib/js/js_mapperRt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function $$throw(loc, x) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "ThrowAny", - _0: x - }; - }) - ], - tl: suites.contents - }; -} - -function aToJs(param) { - return param + 0 | 0; -} - -function aFromJs(param) { - if (!(param <= 2 && 0 <= param)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 1, - -1 - ], - Error: new Error() - }; - } - return param - 0 | 0; -} - -var jsMapperConstantArray = [ - 0, - 3, - 4 -]; - -function bToJs(param) { - return jsMapperConstantArray[param]; -} - -function bFromJs(param) { - return Js_mapperRt.fromIntAssert(3, jsMapperConstantArray, param); -} - -var _map = {"c0":"c0","c1":"c1","c2":"c2"}; - -function cToJs(param) { - return param; -} - -function cFromJs(param) { - return Js_mapperRt.raiseWhenNotFound(_map[param]); -} - -$$throw("File \"ast_mapper_defensive_test.ml\", line 28, characters 16-23", (function (param) { - aFromJs(3); - })); - -$$throw("File \"ast_mapper_defensive_test.ml\", line 29, characters 15-22", (function (param) { - bFromJs(2); - })); - -$$throw("File \"ast_mapper_defensive_test.ml\", line 30, characters 15-22", (function (param) { - cFromJs(33); - })); - -Mt.from_pair_suites("Ast_mapper_defensive_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.$$throw = $$throw; -exports.aToJs = aToJs; -exports.aFromJs = aFromJs; -exports.bToJs = bToJs; -exports.bFromJs = bFromJs; -exports.cToJs = cToJs; -exports.cFromJs = cFromJs; -/* Not a pure module */ diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 0dbdc1cd36..1e32935ee4 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -3211,78 +3211,71 @@ function token(env, lexbuf) { }; } -function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { +function regexp_class(env, buf, lexbuf) { + var ___ocaml_lex_state = 326; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - Lexing.new_line(lexbuf); - ___ocaml_lex_state = 393; - continue ; + return env; case 1 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 393; - continue ; case 2 : - var start = from_lb(env.lex_source, lexbuf); - var buf = $$Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 393; - _env = env$1; - continue ; + break; case 3 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = $$Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 393; - _env = env$2; - continue ; + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + return env; case 4 : - var start$2 = from_lb(env.lex_source, lexbuf); - var cooked = $$Buffer.create(127); - var raw = $$Buffer.create(127); - var literal = $$Buffer.create(127); - $$Buffer.add_string(literal, "}"); - var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$1); + return regexp_class(env, buf, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + $$Buffer.add_string(buf, s); + return regexp_class(env, buf, lexbuf); + }; +} + +function line_comment(env, buf, lexbuf) { + var ___ocaml_lex_state = 287; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : return [ - match$2[0], - { - TAG: "T_TEMPLATE_PART", - _0: [ - match$2[1], - { - cooked: $$Buffer.contents(cooked), - raw: $$Buffer.contents(raw), - literal: $$Buffer.contents(literal) - }, - match$2[2] - ] - } + env, + from_lb(env.lex_source, lexbuf) ]; - case 5 : - var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); + case 1 : + var match = from_lb(env.lex_source, lexbuf); + var match$1 = match._end; + Lexing.new_line(lexbuf); + var _end_line = match$1.line; + var _end_column = match$1.column - 1 | 0; + var _end_offset = match$1.offset - 1 | 0; + var _end = { + line: _end_line, + column: _end_column, + offset: _end_offset + }; return [ - env$3, + env, { - TAG: "T_TEMPLATE_PART", - _0: [ - from_lb(env$3.lex_source, lexbuf), - { - cooked: "", - raw: "", - literal: "" - }, - true - ] + source: match.source, + start: match.start, + _end: _end } ]; + case 2 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + return line_comment(env, buf, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -3357,41 +3350,50 @@ function template_part(env, start, cooked, raw, literal, lexbuf) { }; } -function line_comment(env, buf, lexbuf) { - var ___ocaml_lex_state = 287; +function string_quote(env, q, buf, raw, octal, lexbuf) { + var ___ocaml_lex_state = 247; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; + var q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, q$p); + if (q === q$p) { + return [ + env, + from_lb(env.lex_source, lexbuf), + octal + ]; + } else { + $$Buffer.add_char(buf, q$p); + return string_quote(env, q, buf, raw, octal, lexbuf); + } case 1 : - var match = from_lb(env.lex_source, lexbuf); - var match$1 = match._end; - Lexing.new_line(lexbuf); - var _end_line = match$1.line; - var _end_column = match$1.column - 1 | 0; - var _end_offset = match$1.offset - 1 | 0; - var _end = { - line: _end_line, - column: _end_column, - offset: _end_offset - }; + var e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, e); + var match = string_escape(env, buf, lexbuf); + var octal$1 = match[1] || octal; + $$Buffer.add_string(raw, Lexing.lexeme(lexbuf)); + return string_quote(match[0], q, buf, raw, octal$1, lexbuf); + case 2 : + var x = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, x); + var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); + $$Buffer.add_string(buf, x); return [ - env, - { - source: match.source, - start: match.start, - _end: _end - } + env$1, + from_lb(env$1.lex_source, lexbuf), + octal ]; - case 2 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - return line_comment(env, buf, lexbuf); + case 3 : + var x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(raw, x$1); + $$Buffer.add_char(buf, x$1); + return string_quote(env, q, buf, raw, octal, lexbuf); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -3448,327 +3450,362 @@ function comment(env, buf, lexbuf) { }; } -function string_quote(env, q, buf, raw, octal, lexbuf) { - var ___ocaml_lex_state = 247; +function type_token(env, lexbuf) { + lexbuf.lex_mem = Caml_array.make(26, -1); + Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); + Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); + var ___ocaml_lex_state = 133; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - var q$p = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, q$p); - if (q === q$p) { - return [ - env, - from_lb(env.lex_source, lexbuf), - octal - ]; - } else { - $$Buffer.add_char(buf, q$p); - return string_quote(env, q, buf, raw, octal, lexbuf); - } + Lexing.new_line(lexbuf); + return type_token(env, lexbuf); case 1 : - var e = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, e); - var match = string_escape(env, buf, lexbuf); - var octal$1 = match[1] || octal; - $$Buffer.add_string(raw, Lexing.lexeme(lexbuf)); - return string_quote(match[0], q, buf, raw, octal$1, lexbuf); + unicode_fix_cols(lexbuf); + return type_token(env, lexbuf); case 2 : - var x = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, x); - var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); - $$Buffer.add_string(buf, x); - return [ - env$1, - from_lb(env$1.lex_source, lexbuf), - octal - ]; + var start = from_lb(env.lex_source, lexbuf); + var buf = $$Buffer.create(127); + var match = comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + return type_token(env$1, lexbuf); case 3 : - var x$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(raw, x$1); - $$Buffer.add_char(buf, x$1); - return string_quote(env, q, buf, raw, octal, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function string_escape(env, buf, lexbuf) { - var ___ocaml_lex_state = 252; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return [ - env, - false - ]; - case 1 : - $$Buffer.add_string(buf, "\\"); - return [ - env, - false - ]; - case 2 : - var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code)); - return [ - env, - false - ]; - case 3 : - var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; - if (code$1 < 256) { - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$1)); - } else { - var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$2)); - $$Buffer.add_char(buf, c); + var sp = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); + var escape_type = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + var pattern = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + if (env.lex_enable_comment_syntax) { + var env$2; + if (env.lex_in_comment_syntax) { + var loc = from_lb(env.lex_source, lexbuf); + env$2 = unexpected_error(env, loc, pattern); + } else { + env$2 = env; + } + var env$3 = in_comment_syntax(true, env$2); + if (escape_type === ":") { + return [ + env$3, + "T_COLON" + ]; + } else { + return type_token(env$3, lexbuf); + } } - return [ - env, - true - ]; + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = $$Buffer.create(127); + $$Buffer.add_string(buf$1, sp); + $$Buffer.add_string(buf$1, escape_type); + var match$1 = comment(env, buf$1, lexbuf); + var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + return type_token(env$4, lexbuf); case 4 : - var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$3)); + if (env.lex_in_comment_syntax) { + var env$5 = in_comment_syntax(false, env); + return type_token(env$5, lexbuf); + } + yyback(1, lexbuf); return [ env, - true + "T_MULT" ]; case 5 : - $$Buffer.add_char(buf, Char.chr(0)); - return [ - env, - false - ]; + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = $$Buffer.create(127); + var match$2 = line_comment(env, buf$2, lexbuf); + var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); + return type_token(env$6, lexbuf); case 6 : - $$Buffer.add_char(buf, Char.chr(8)); + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var start$3 = from_lb(env.lex_source, lexbuf); + var buf$3 = $$Buffer.create(127); + var raw = $$Buffer.create(127); + $$Buffer.add_char(raw, quote); + var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); return [ - env, - false + match$3[0], + { + TAG: "T_STRING", + _0: [ + btwn(start$3, match$3[1]), + $$Buffer.contents(buf$3), + $$Buffer.contents(raw), + match$3[2] + ] + } ]; case 7 : - $$Buffer.add_char(buf, Char.chr(12)); - return [ - env, - false - ]; + var neg = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w, mk_num_singleton("BINARY", num, neg)); case 8 : - $$Buffer.add_char(buf, Char.chr(10)); + var neg$1 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton("BINARY", num$1, neg$1) ]; case 9 : - $$Buffer.add_char(buf, Char.chr(13)); - return [ - env, - false - ]; + var neg$2 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$1, mk_num_singleton("OCTAL", num$2, neg$2)); case 10 : - $$Buffer.add_char(buf, Char.chr(9)); + var neg$3 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton("OCTAL", num$3, neg$3) ]; case 11 : - $$Buffer.add_char(buf, Char.chr(11)); - return [ - env, - false - ]; + var neg$4 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$2, mk_num_singleton("LEGACY_OCTAL", num$4, neg$4)); case 12 : - var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var code$4 = oct_to_int(a$3); - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$4)); + var neg$5 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - true + mk_num_singleton("LEGACY_OCTAL", num$5, neg$5) ]; case 13 : - var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); - var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); - var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); - var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$5)); - return [ - env, - false - ]; + var neg$6 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$6 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + var match$4; + try { + match$4 = [ + env, + mk_num_singleton("NORMAL", num$6, neg$6) + ]; + } + catch (exn){ + if (Sys.win32) { + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$7 = lex_error(env, loc$1, "WindowsFloatOfString"); + match$4 = [ + env$7, + { + TAG: "T_NUMBER_SINGLETON_TYPE", + _0: "NORMAL", + _1: 789.0 + } + ]; + } else { + throw exn; + } + } + return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); case 14 : - var hex_code = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); - var code$6 = Caml_format.int_of_string("0x" + hex_code); - var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }) : env; - List.iter((function (param) { - return $$Buffer.add_char(buf, param); - }), utf16to8(code$6)); - return [ - env$1, - false - ]; + var neg$7 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$7 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + try { + return [ + env, + mk_num_singleton("NORMAL", num$7, neg$7) + ]; + } + catch (exn$1){ + if (Sys.win32) { + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$8 = lex_error(env, loc$2, "WindowsFloatOfString"); + return [ + env$8, + { + TAG: "T_NUMBER_SINGLETON_TYPE", + _0: "NORMAL", + _1: 789.0 + } + ]; + } + throw exn$1; + } case 15 : - var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); - $$Buffer.add_char(buf, c$2); - return [ - env$2, - false - ]; + var neg$8 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$8 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$4, mk_num_singleton("NORMAL", num$8, neg$8)); case 16 : - Lexing.new_line(lexbuf); + var neg$9 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$9 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - false + mk_num_singleton("NORMAL", num$9, neg$9) ]; case 17 : - var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$3); + var neg$10 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); + var num$10 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); + var w$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); + return illegal_number(env, lexbuf, w$5, mk_num_singleton("NORMAL", num$10, neg$10)); + case 18 : + var neg$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); + var num$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); return [ env, - false + mk_num_singleton("NORMAL", num$11, neg$11) ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : + case 19 : + var word = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + unicode_fix_cols(lexbuf); + try { + return [ + env, + Hashtbl.find(type_keywords, word) + ]; + } + catch (raw_exn){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn$2.RE_EXN_ID === "Not_found") { + return [ + env, + "T_IDENTIFIER" + ]; + } + throw exn$2; + } + case 22 : return [ env, - "T_EOF" + "T_LCURLY" ]; - case 1 : - Lexing.new_line(lexbuf); - ___ocaml_lex_state = 333; - continue ; - case 2 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 333; - continue ; - case 3 : - var start = from_lb(env.lex_source, lexbuf); - var buf = $$Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 333; - _env = env$1; - continue ; - case 4 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = $$Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 333; - _env = env$2; - continue ; - case 5 : + case 23 : return [ env, - "T_LESS_THAN" + "T_RCURLY" ]; - case 6 : + case 24 : return [ env, - "T_DIV" + "T_LPAREN" ]; - case 7 : + case 25 : + return [ + env, + "T_RPAREN" + ]; + case 26 : + return [ + env, + "T_ELLIPSIS" + ]; + case 27 : + return [ + env, + "T_PERIOD" + ]; + case 28 : + return [ + env, + "T_SEMICOLON" + ]; + case 29 : + return [ + env, + "T_COMMA" + ]; + case 20 : + case 32 : + return [ + env, + "T_LBRACKET" + ]; + case 21 : + case 33 : + return [ + env, + "T_RBRACKET" + ]; + case 34 : + return [ + env, + "T_LESS_THAN" + ]; + case 35 : return [ env, "T_GREATER_THAN" ]; - case 8 : + case 31 : + case 37 : return [ env, - "T_LCURLY" + "T_PLING" ]; - case 9 : + case 38 : + return [ + env, + "T_MULT" + ]; + case 30 : + case 39 : return [ env, "T_COLON" ]; - case 10 : + case 40 : return [ env, - "T_PERIOD" + "T_BIT_OR" ]; - case 11 : + case 41 : + return [ + env, + "T_BIT_AND" + ]; + case 42 : + return [ + env, + "T_TYPEOF" + ]; + case 43 : + return [ + env, + "T_ARROW" + ]; + case 36 : + case 44 : return [ env, "T_ASSIGN" ]; - case 12 : - unicode_fix_cols(lexbuf); + case 45 : return [ env, - "T_JSX_IDENTIFIER" + "T_PLUS" ]; - case 13 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = $$Buffer.create(127); - var raw = $$Buffer.create(127); - $$Buffer.add_char(raw, quote); - var mode = quote === /* '\'' */39 ? "JSX_SINGLE_QUOTED_TEXT" : "JSX_DOUBLE_QUOTED_TEXT"; - var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); - $$Buffer.add_char(raw, quote); - var value = $$Buffer.contents(buf$2); - var raw$1 = $$Buffer.contents(raw); + case 46 : return [ - match$2[0], - { - TAG: "T_JSX_TEXT", - _0: [ - btwn(start$2, match$2[1]), - value, - raw$1 - ] - } + env, + "T_MINUS" ]; - case 14 : + case 47 : + var env$9; + if (env.lex_in_comment_syntax) { + var loc$3 = from_lb(env.lex_source, lexbuf); + env$9 = lex_error(env, loc$3, "UnexpectedEOS"); + } else { + env$9 = env; + } + return [ + env$9, + "T_EOF" + ]; + case 48 : return [ env, "T_ERROR" @@ -3781,68 +3818,148 @@ function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { }; } -function jsx_text(env, mode, buf, raw, lexbuf) { - var ___ocaml_lex_state = 371; +function __ocaml_lex_template_tail_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - switch (mode) { - case "JSX_SINGLE_QUOTED_TEXT" : - if (c === 39) { - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - case "JSX_DOUBLE_QUOTED_TEXT" : - if (c === 34) { - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - case "JSX_CHILD_TEXT" : - var exit = 0; - if (!(c !== 60 && c !== 123)) { - exit = 2; - } - if (exit === 2) { - back(lexbuf); - return [ - env, - from_lb(env.lex_source, lexbuf) - ]; - } - break; - - } - $$Buffer.add_char(raw, c); - $$Buffer.add_char(buf, c); - return jsx_text(env, mode, buf, raw, lexbuf); + Lexing.new_line(lexbuf); + ___ocaml_lex_state = 393; + continue ; case 1 : - var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { - TAG: "UnexpectedToken", - _0: "ILLEGAL" - }); - return [ - env$1, - from_lb(env$1.lex_source, lexbuf) - ]; + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 393; + continue ; case 2 : - var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, lt); - $$Buffer.add_string(buf, lt); - Lexing.new_line(lexbuf); - return jsx_text(env, mode, buf, raw, lexbuf); + var start = from_lb(env.lex_source, lexbuf); + var buf = $$Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 393; + _env = env$1; + continue ; case 3 : - var n = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 3 | 0, lexbuf.lex_curr_pos - 1 | 0); - var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, s); + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = $$Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 393; + _env = env$2; + continue ; + case 4 : + var start$2 = from_lb(env.lex_source, lexbuf); + var cooked = $$Buffer.create(127); + var raw = $$Buffer.create(127); + var literal = $$Buffer.create(127); + $$Buffer.add_string(literal, "}"); + var match$2 = template_part(env, start$2, cooked, raw, literal, lexbuf); + return [ + match$2[0], + { + TAG: "T_TEMPLATE_PART", + _0: [ + match$2[1], + { + cooked: $$Buffer.contents(cooked), + raw: $$Buffer.contents(raw), + literal: $$Buffer.contents(literal) + }, + match$2[2] + ] + } + ]; + case 5 : + var env$3 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); + return [ + env$3, + { + TAG: "T_TEMPLATE_PART", + _0: [ + from_lb(env$3.lex_source, lexbuf), + { + cooked: "", + raw: "", + literal: "" + }, + true + ] + } + ]; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function jsx_text(env, mode, buf, raw, lexbuf) { + var ___ocaml_lex_state = 371; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + switch (mode) { + case "JSX_SINGLE_QUOTED_TEXT" : + if (c === 39) { + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } + break; + case "JSX_DOUBLE_QUOTED_TEXT" : + if (c === 34) { + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } + break; + case "JSX_CHILD_TEXT" : + var exit = 0; + if (!(c !== 60 && c !== 123)) { + exit = 2; + } + if (exit === 2) { + back(lexbuf); + return [ + env, + from_lb(env.lex_source, lexbuf) + ]; + } + break; + + } + $$Buffer.add_char(raw, c); + $$Buffer.add_char(buf, c); + return jsx_text(env, mode, buf, raw, lexbuf); + case 1 : + var env$1 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); + return [ + env$1, + from_lb(env$1.lex_source, lexbuf) + ]; + case 2 : + var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, lt); + $$Buffer.add_string(buf, lt); + Lexing.new_line(lexbuf); + return jsx_text(env, mode, buf, raw, lexbuf); + case 3 : + var n = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 3 | 0, lexbuf.lex_curr_pos - 1 | 0); + var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, s); var code = Caml_format.int_of_string("0x" + n); List.iter((function (param) { return $$Buffer.add_char(buf, param); @@ -4646,156 +4763,167 @@ function jsx_text(env, mode, buf, raw, lexbuf) { }; } -function regexp_class(env, buf, lexbuf) { - var ___ocaml_lex_state = 326; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return env; - case 1 : - case 2 : - break; - case 3 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - return env; - case 4 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$1); - return regexp_class(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - $$Buffer.add_string(buf, s); - return regexp_class(env, buf, lexbuf); - }; -} - -function regexp_body(env, buf, lexbuf) { - var ___ocaml_lex_state = 314; +function string_escape(env, buf, lexbuf) { + var ___ocaml_lex_state = 252; while(true) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - var loc = from_lb(env.lex_source, lexbuf); - var env$1 = lex_error(env, loc, "UnterminatedRegExp"); return [ - env$1, - "" + env, + false ]; case 1 : - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$2 = lex_error(env, loc$1, "UnterminatedRegExp"); + $$Buffer.add_string(buf, "\\"); return [ - env$2, - "" + env, + false ]; case 2 : - var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); - $$Buffer.add_string(buf, s); - return regexp_body(env, buf, lexbuf); + var a = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code = (hexa_to_int(a) << 4) + hexa_to_int(b) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code)); + return [ + env, + false + ]; case 3 : - var flags = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); + var a$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var code$1 = ((oct_to_int(a$1) << 6) + (oct_to_int(b$1) << 3) | 0) + oct_to_int(c) | 0; + if (code$1 < 256) { + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$1)); + } else { + var code$2 = (oct_to_int(a$1) << 3) + oct_to_int(b$1) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$2)); + $$Buffer.add_char(buf, c); + } return [ env, - flags + true ]; case 4 : + var a$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var b$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var code$3 = (oct_to_int(a$2) << 3) + oct_to_int(b$2) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$3)); return [ env, - "" + true ]; case 5 : - var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c); - var env$3 = regexp_class(env, buf, lexbuf); - return regexp_body(env$3, buf, lexbuf); + $$Buffer.add_char(buf, Char.chr(0)); + return [ + env, + false + ]; case 6 : - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$4 = lex_error(env, loc$2, "UnterminatedRegExp"); + $$Buffer.add_char(buf, Char.chr(8)); return [ - env$4, - "" + env, + false ]; case 7 : - var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - $$Buffer.add_char(buf, c$1); - return regexp_body(env, buf, lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var env = _env; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : + $$Buffer.add_char(buf, Char.chr(12)); return [ env, - "T_EOF" + false ]; - case 1 : - Lexing.new_line(lexbuf); - ___ocaml_lex_state = 291; - continue ; - case 2 : - unicode_fix_cols(lexbuf); - ___ocaml_lex_state = 291; - continue ; - case 3 : - var start = from_lb(env.lex_source, lexbuf); - var buf = $$Buffer.create(127); - var match = line_comment(env, buf, lexbuf); - var env$1 = save_comment(match[0], start, match[1], buf, true); - ___ocaml_lex_state = 291; - _env = env$1; - continue ; - case 4 : - var start$1 = from_lb(env.lex_source, lexbuf); - var buf$1 = $$Buffer.create(127); - var match$1 = comment(env, buf$1, lexbuf); - var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - ___ocaml_lex_state = 291; - _env = env$2; - continue ; - case 5 : - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = $$Buffer.create(127); - var match$2 = regexp_body(env, buf$2, lexbuf); - var env$3 = match$2[0]; - var end_ = from_lb(env$3.lex_source, lexbuf); - var loc = btwn(start$2, end_); + case 8 : + $$Buffer.add_char(buf, Char.chr(10)); return [ - env$3, - { - TAG: "T_REGEXP", - _0: [ - loc, - $$Buffer.contents(buf$2), - match$2[1] - ] - } + env, + false ]; - case 6 : - var env$4 = lex_error(env, from_lb(env.lex_source, lexbuf), { + case 9 : + $$Buffer.add_char(buf, Char.chr(13)); + return [ + env, + false + ]; + case 10 : + $$Buffer.add_char(buf, Char.chr(9)); + return [ + env, + false + ]; + case 11 : + $$Buffer.add_char(buf, Char.chr(11)); + return [ + env, + false + ]; + case 12 : + var a$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var code$4 = oct_to_int(a$3); + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$4)); + return [ + env, + true + ]; + case 13 : + var a$4 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 1 | 0); + var b$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 2 | 0); + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 3 | 0); + var d = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + 4 | 0); + var code$5 = (((hexa_to_int(a$4) << 12) + (hexa_to_int(b$3) << 8) | 0) + (hexa_to_int(c$1) << 4) | 0) + hexa_to_int(d) | 0; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$5)); + return [ + env, + false + ]; + case 14 : + var hex_code = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, lexbuf.lex_curr_pos - 1 | 0); + var code$6 = Caml_format.int_of_string("0x" + hex_code); + var env$1 = code$6 > 1114111 ? lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }) : env; + List.iter((function (param) { + return $$Buffer.add_char(buf, param); + }), utf16to8(code$6)); + return [ + env$1, + false + ]; + case 15 : + var c$2 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var env$2 = lex_error(env, from_lb(env.lex_source, lexbuf), { TAG: "UnexpectedToken", _0: "ILLEGAL" }); + $$Buffer.add_char(buf, c$2); return [ - env$4, - "T_ERROR" + env$2, + false + ]; + case 16 : + Lexing.new_line(lexbuf); + return [ + env, + false + ]; + case 17 : + var c$3 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$3); + return [ + env, + false ]; default: Curry._1(lexbuf.refill_buff, lexbuf); @@ -4805,388 +4933,260 @@ function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { }; } -function type_token(env, lexbuf) { - lexbuf.lex_mem = Caml_array.make(26, -1); - Caml_array.set(lexbuf.lex_mem, 17, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 16, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 15, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 14, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 13, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 12, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 11, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 10, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 9, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 8, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 7, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 6, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 5, lexbuf.lex_curr_pos); - Caml_array.set(lexbuf.lex_mem, 4, lexbuf.lex_curr_pos); - var ___ocaml_lex_state = 133; +function __ocaml_lex_jsx_tag_rec(_env, lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + var env = _env; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - Lexing.new_line(lexbuf); - return type_token(env, lexbuf); + return [ + env, + "T_EOF" + ]; case 1 : - unicode_fix_cols(lexbuf); - return type_token(env, lexbuf); + Lexing.new_line(lexbuf); + ___ocaml_lex_state = 333; + continue ; case 2 : + unicode_fix_cols(lexbuf); + ___ocaml_lex_state = 333; + continue ; + case 3 : var start = from_lb(env.lex_source, lexbuf); var buf = $$Buffer.create(127); - var match = comment(env, buf, lexbuf); + var match = line_comment(env, buf, lexbuf); var env$1 = save_comment(match[0], start, match[1], buf, true); - return type_token(env$1, lexbuf); - case 3 : - var sp = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 2 | 0, Caml_array.get(lexbuf.lex_mem, 0)); - var escape_type = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - var pattern = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - if (env.lex_enable_comment_syntax) { - var env$2; - if (env.lex_in_comment_syntax) { - var loc = from_lb(env.lex_source, lexbuf); - env$2 = unexpected_error(env, loc, pattern); - } else { - env$2 = env; - } - var env$3 = in_comment_syntax(true, env$2); - if (escape_type === ":") { - return [ - env$3, - "T_COLON" - ]; - } else { - return type_token(env$3, lexbuf); - } - } + ___ocaml_lex_state = 333; + _env = env$1; + continue ; + case 4 : var start$1 = from_lb(env.lex_source, lexbuf); var buf$1 = $$Buffer.create(127); - $$Buffer.add_string(buf$1, sp); - $$Buffer.add_string(buf$1, escape_type); var match$1 = comment(env, buf$1, lexbuf); - var env$4 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); - return type_token(env$4, lexbuf); - case 4 : - if (env.lex_in_comment_syntax) { - var env$5 = in_comment_syntax(false, env); - return type_token(env$5, lexbuf); - } - yyback(1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 333; + _env = env$2; + continue ; + case 5 : return [ env, - "T_MULT" + "T_LESS_THAN" ]; - case 5 : - var start$2 = from_lb(env.lex_source, lexbuf); - var buf$2 = $$Buffer.create(127); - var match$2 = line_comment(env, buf$2, lexbuf); - var env$6 = save_comment(match$2[0], start$2, match$2[1], buf$2, true); - return type_token(env$6, lexbuf); case 6 : - var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); - var start$3 = from_lb(env.lex_source, lexbuf); - var buf$3 = $$Buffer.create(127); - var raw = $$Buffer.create(127); - $$Buffer.add_char(raw, quote); - var match$3 = string_quote(env, quote, buf$3, raw, false, lexbuf); return [ - match$3[0], - { - TAG: "T_STRING", - _0: [ - btwn(start$3, match$3[1]), - $$Buffer.contents(buf$3), - $$Buffer.contents(raw), - match$3[2] - ] - } + env, + "T_DIV" ]; case 7 : - var neg = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w, mk_num_singleton("BINARY", num, neg)); + return [ + env, + "T_GREATER_THAN" + ]; case 8 : - var neg$1 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - mk_num_singleton("BINARY", num$1, neg$1) + "T_LCURLY" ]; case 9 : - var neg$2 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$1 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$1, mk_num_singleton("OCTAL", num$2, neg$2)); + return [ + env, + "T_COLON" + ]; case 10 : - var neg$3 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - mk_num_singleton("OCTAL", num$3, neg$3) + "T_PERIOD" ]; case 11 : - var neg$4 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$2 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$2, mk_num_singleton("LEGACY_OCTAL", num$4, neg$4)); + return [ + env, + "T_ASSIGN" + ]; case 12 : - var neg$5 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + unicode_fix_cols(lexbuf); return [ env, - mk_num_singleton("LEGACY_OCTAL", num$5, neg$5) + "T_JSX_IDENTIFIER" ]; case 13 : - var neg$6 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$6 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$3 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - var match$4; - try { - match$4 = [ - env, - mk_num_singleton("NORMAL", num$6, neg$6) - ]; - } - catch (exn){ - if (Sys.win32) { - var loc$1 = from_lb(env.lex_source, lexbuf); - var env$7 = lex_error(env, loc$1, "WindowsFloatOfString"); - match$4 = [ - env$7, - { - TAG: "T_NUMBER_SINGLETON_TYPE", - _0: "NORMAL", - _1: 789.0 - } - ]; - } else { - throw exn; - } - } - return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); + var quote = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = $$Buffer.create(127); + var raw = $$Buffer.create(127); + $$Buffer.add_char(raw, quote); + var mode = quote === /* '\'' */39 ? "JSX_SINGLE_QUOTED_TEXT" : "JSX_DOUBLE_QUOTED_TEXT"; + var match$2 = jsx_text(env, mode, buf$2, raw, lexbuf); + $$Buffer.add_char(raw, quote); + var value = $$Buffer.contents(buf$2); + var raw$1 = $$Buffer.contents(raw); + return [ + match$2[0], + { + TAG: "T_JSX_TEXT", + _0: [ + btwn(start$2, match$2[1]), + value, + raw$1 + ] + } + ]; case 14 : - var neg$7 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$7 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - try { - return [ - env, - mk_num_singleton("NORMAL", num$7, neg$7) - ]; - } - catch (exn$1){ - if (Sys.win32) { - var loc$2 = from_lb(env.lex_source, lexbuf); - var env$8 = lex_error(env, loc$2, "WindowsFloatOfString"); - return [ - env$8, - { - TAG: "T_NUMBER_SINGLETON_TYPE", - _0: "NORMAL", - _1: 789.0 - } - ]; - } - throw exn$1; - } - case 15 : - var neg$8 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$8 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$4 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$4, mk_num_singleton("NORMAL", num$8, neg$8)); - case 16 : - var neg$9 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$9 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); return [ env, - mk_num_singleton("NORMAL", num$9, neg$9) + "T_ERROR" ]; - case 17 : - var neg$10 = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); - var num$10 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), Caml_array.get(lexbuf.lex_mem, 1)); - var w$5 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), lexbuf.lex_curr_pos); - return illegal_number(env, lexbuf, w$5, mk_num_singleton("NORMAL", num$10, neg$10)); - case 18 : - var neg$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 1), Caml_array.get(lexbuf.lex_mem, 0)); - var num$11 = Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 3), Caml_array.get(lexbuf.lex_mem, 2)); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function __ocaml_lex_regexp_rec(_env, lexbuf, ___ocaml_lex_state) { + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var env = _env; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : return [ env, - mk_num_singleton("NORMAL", num$11, neg$11) + "T_EOF" ]; - case 19 : - var word = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + case 1 : + Lexing.new_line(lexbuf); + ___ocaml_lex_state = 291; + continue ; + case 2 : unicode_fix_cols(lexbuf); - try { - return [ - env, - Hashtbl.find(type_keywords, word) - ]; - } - catch (raw_exn){ - var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn$2.RE_EXN_ID === "Not_found") { - return [ - env, - "T_IDENTIFIER" - ]; - } - throw exn$2; - } - case 22 : + ___ocaml_lex_state = 291; + continue ; + case 3 : + var start = from_lb(env.lex_source, lexbuf); + var buf = $$Buffer.create(127); + var match = line_comment(env, buf, lexbuf); + var env$1 = save_comment(match[0], start, match[1], buf, true); + ___ocaml_lex_state = 291; + _env = env$1; + continue ; + case 4 : + var start$1 = from_lb(env.lex_source, lexbuf); + var buf$1 = $$Buffer.create(127); + var match$1 = comment(env, buf$1, lexbuf); + var env$2 = save_comment(match$1[0], start$1, match$1[1], buf$1, true); + ___ocaml_lex_state = 291; + _env = env$2; + continue ; + case 5 : + var start$2 = from_lb(env.lex_source, lexbuf); + var buf$2 = $$Buffer.create(127); + var match$2 = regexp_body(env, buf$2, lexbuf); + var env$3 = match$2[0]; + var end_ = from_lb(env$3.lex_source, lexbuf); + var loc = btwn(start$2, end_); return [ - env, - "T_LCURLY" + env$3, + { + TAG: "T_REGEXP", + _0: [ + loc, + $$Buffer.contents(buf$2), + match$2[1] + ] + } ]; - case 23 : + case 6 : + var env$4 = lex_error(env, from_lb(env.lex_source, lexbuf), { + TAG: "UnexpectedToken", + _0: "ILLEGAL" + }); return [ - env, - "T_RCURLY" + env$4, + "T_ERROR" ]; - case 24 : + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function regexp_body(env, buf, lexbuf) { + var ___ocaml_lex_state = 314; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var loc = from_lb(env.lex_source, lexbuf); + var env$1 = lex_error(env, loc, "UnterminatedRegExp"); return [ - env, - "T_LPAREN" + env$1, + "" ]; - case 25 : + case 1 : + var loc$1 = from_lb(env.lex_source, lexbuf); + var env$2 = lex_error(env, loc$1, "UnterminatedRegExp"); return [ - env, - "T_RPAREN" + env$2, + "" ]; - case 26 : + case 2 : + var s = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_start_pos + 2 | 0); + $$Buffer.add_string(buf, s); + return regexp_body(env, buf, lexbuf); + case 3 : + var flags = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos + 1 | 0, lexbuf.lex_curr_pos); return [ env, - "T_ELLIPSIS" + flags ]; - case 27 : + case 4 : return [ env, - "T_PERIOD" + "" ]; - case 28 : + case 5 : + var c = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c); + var env$3 = regexp_class(env, buf, lexbuf); + return regexp_body(env$3, buf, lexbuf); + case 6 : + var loc$2 = from_lb(env.lex_source, lexbuf); + var env$4 = lex_error(env, loc$2, "UnterminatedRegExp"); return [ - env, - "T_SEMICOLON" + env$4, + "" ]; - case 29 : - return [ - env, - "T_COMMA" - ]; - case 20 : - case 32 : - return [ - env, - "T_LBRACKET" - ]; - case 21 : - case 33 : - return [ - env, - "T_RBRACKET" - ]; - case 34 : - return [ - env, - "T_LESS_THAN" - ]; - case 35 : - return [ - env, - "T_GREATER_THAN" - ]; - case 31 : - case 37 : - return [ - env, - "T_PLING" - ]; - case 38 : - return [ - env, - "T_MULT" - ]; - case 30 : - case 39 : - return [ - env, - "T_COLON" - ]; - case 40 : - return [ - env, - "T_BIT_OR" - ]; - case 41 : - return [ - env, - "T_BIT_AND" - ]; - case 42 : - return [ - env, - "T_TYPEOF" - ]; - case 43 : - return [ - env, - "T_ARROW" - ]; - case 36 : - case 44 : - return [ - env, - "T_ASSIGN" - ]; - case 45 : - return [ - env, - "T_PLUS" - ]; - case 46 : - return [ - env, - "T_MINUS" - ]; - case 47 : - var env$9; - if (env.lex_in_comment_syntax) { - var loc$3 = from_lb(env.lex_source, lexbuf); - env$9 = lex_error(env, loc$3, "UnexpectedEOS"); - } else { - env$9 = env; - } - return [ - env$9, - "T_EOF" - ]; - case 48 : - return [ - env, - "T_ERROR" - ]; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function jsx_child(env, start, buf, raw, lexbuf) { - var ___ocaml_lex_state = 364; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); - $$Buffer.add_string(raw, lt); - $$Buffer.add_string(buf, lt); - Lexing.new_line(lexbuf); - var match = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); - var value = $$Buffer.contents(buf); - var raw$1 = $$Buffer.contents(raw); + case 7 : + var c$1 = Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos); + $$Buffer.add_char(buf, c$1); + return regexp_body(env, buf, lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function jsx_child(env, start, buf, raw, lexbuf) { + var ___ocaml_lex_state = 364; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + var lt = Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, lexbuf.lex_curr_pos); + $$Buffer.add_string(raw, lt); + $$Buffer.add_string(buf, lt); + Lexing.new_line(lexbuf); + var match = jsx_text(env, "JSX_CHILD_TEXT", buf, raw, lexbuf); + var value = $$Buffer.contents(buf); + var raw$1 = $$Buffer.contents(raw); return [ match[0], { @@ -6733,116 +6733,6 @@ var Parse = Caml_module.init_mod([ ] }); -function union(env) { - maybe(env, "T_BIT_OR"); - var left = intersection(env); - return Curry._2(union_with, env, left); -} - -function param_list_or_type(env) { - token$4(env, "T_LPAREN"); - var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); - var ret; - var exit = 0; - if (typeof token$5 !== "object") { - switch (token$5) { - case "T_IDENTIFIER" : - ret = function_param_or_generic_type(env); - break; - case "T_RPAREN" : - ret = { - TAG: "ParamList", - _0: [ - undefined, - /* [] */0 - ] - }; - break; - case "T_ELLIPSIS" : - case "T_EOF" : - ret = { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, /* [] */0) - }; - break; - default: - exit = 1; - } - } else { - exit = 1; - } - if (exit === 1) { - var match = primitive(token$5); - if (match !== undefined) { - var match$1 = Curry._2(Parser_env_Peek.token, 1, env); - var exit$1 = 0; - if (typeof match$1 !== "object") { - switch (match$1) { - case "T_PLING" : - case "T_COLON" : - exit$1 = 2; - break; - default: - ret = { - TAG: "Type", - _0: union(env) - }; - } - } else { - ret = { - TAG: "Type", - _0: union(env) - }; - } - if (exit$1 === 2) { - var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var name = match$2[0]; - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); - } - var optional = maybe(env, "T_PLING"); - token$4(env, "T_COLON"); - var typeAnnotation = union(env); - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RPAREN") { - token$4(env, "T_COMMA"); - } - var param_0 = btwn(name[0], typeAnnotation[0]); - var param_1 = { - name: name, - typeAnnotation: typeAnnotation, - optional: optional - }; - var param = [ - param_0, - param_1 - ]; - ret = { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - } - - } else { - ret = { - TAG: "Type", - _0: union(env) - }; - } - } - token$4(env, "T_RPAREN"); - return ret; -} - -function function_param_list(env) { - token$4(env, "T_LPAREN"); - var ret = Curry._2(function_param_list_without_parens, env, /* [] */0); - token$4(env, "T_RPAREN"); - return ret; -} - function prefix(env) { var match = Curry._2(Parser_env_Peek.token, undefined, env); if (typeof match === "object") { @@ -6863,17 +6753,6 @@ function prefix(env) { ]; } -function postfix(env) { - var t = primary(env); - return postfix_with(env, t); -} - -function intersection(env) { - maybe(env, "T_BIT_AND"); - var left = prefix(env); - return Curry._2(intersection_with, env, left); -} - function rev_nonempty_acc(acc) { var end_loc; if (acc) { @@ -6910,112 +6789,27 @@ function rev_nonempty_acc(acc) { ]; } -function function_param_with_id(env, name) { - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); - } - var optional = maybe(env, "T_PLING"); - token$4(env, "T_COLON"); - var typeAnnotation = union(env); - return [ - btwn(name[0], typeAnnotation[0]), - { - name: name, - typeAnnotation: typeAnnotation, - optional: optional - } - ]; +function intersection(env) { + maybe(env, "T_BIT_AND"); + var left = prefix(env); + return Curry._2(intersection_with, env, left); } -function generic_type_with_identifier(env, id) { - var match = Curry._2(raw_generic_with_identifier, env, id); - return [ - match[0], - { - TAG: "Generic", - _0: match[1] - } - ]; -} - -function postfix_with(env, _t) { - while(true) { - var t = _t; - if (!(!Curry._1(Parser_env_Peek.is_line_terminator, env) && maybe(env, "T_LBRACKET"))) { - return t; - } - var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_RBRACKET"); - var loc = btwn(t[0], end_loc); - var t_1 = { - TAG: "Array", - _0: t - }; - var t$1 = [ - loc, - t_1 - ]; - _t = t$1; - continue ; - }; +function function_param_list(env) { + token$4(env, "T_LPAREN"); + var ret = Curry._2(function_param_list_without_parens, env, /* [] */0); + token$4(env, "T_RPAREN"); + return ret; } -function primitive(param) { - if (typeof param === "object") { - return ; - } - switch (param) { - case "T_NULL" : - return "Null"; - case "T_ANY_TYPE" : - return "Any"; - case "T_BOOLEAN_TYPE" : - return "Boolean"; - case "T_NUMBER_TYPE" : - return "Number"; - case "T_STRING_TYPE" : - return "String"; - case "T_VOID_TYPE" : - return "Void"; - default: - return ; - } +function union(env) { + maybe(env, "T_BIT_OR"); + var left = intersection(env); + return Curry._2(union_with, env, left); } -function function_param_or_generic_type(env) { - var id = Curry._2(Parse.identifier, undefined, env); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - if (typeof match !== "object") { - switch (match) { - case "T_PLING" : - case "T_COLON" : - exit = 2; - break; - default: - exit = 1; - } - } else { - exit = 1; - } - switch (exit) { - case 1 : - return { - TAG: "Type", - _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) - }; - case 2 : - var param = function_param_with_id(env, id); - maybe(env, "T_COMMA"); - return { - TAG: "ParamList", - _0: Curry._2(function_param_list_without_parens, env, { - hd: param, - tl: /* [] */0 - }) - }; - - } +function generic(env) { + return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); } function primary(env) { @@ -7210,178 +7004,218 @@ function primary(env) { } } -function generic(env) { - return Curry._2(raw_generic_with_identifier, env, Curry._2(Parse.identifier, undefined, env)); +function primitive(param) { + if (typeof param === "object") { + return ; + } + switch (param) { + case "T_NULL" : + return "Null"; + case "T_ANY_TYPE" : + return "Any"; + case "T_BOOLEAN_TYPE" : + return "Boolean"; + case "T_NUMBER_TYPE" : + return "Number"; + case "T_STRING_TYPE" : + return "String"; + case "T_VOID_TYPE" : + return "Void"; + default: + return ; + } } -function identifier(env, _param) { +function function_param_with_id(env, name) { + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + var optional = maybe(env, "T_PLING"); + token$4(env, "T_COLON"); + var typeAnnotation = union(env); + return [ + btwn(name[0], typeAnnotation[0]), + { + name: name, + typeAnnotation: typeAnnotation, + optional: optional + } + ]; +} + +function postfix_with(env, _t) { while(true) { - var param = _param; - var qualification = param[1]; - var q_loc = param[0]; - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_PERIOD") { - return [ - q_loc, - qualification - ]; + var t = _t; + if (!(!Curry._1(Parser_env_Peek.is_line_terminator, env) && maybe(env, "T_LBRACKET"))) { + return t; } - token$4(env, "T_PERIOD"); - var id = Curry._2(Parse.identifier, undefined, env); - var loc = btwn(q_loc, id[0]); - var qualification$1 = { - TAG: "Qualified", - _0: [ - loc, - { - qualification: qualification, - id: id - } - ] + var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_RBRACKET"); + var loc = btwn(t[0], end_loc); + var t_1 = { + TAG: "Array", + _0: t }; - _param = [ + var t$1 = [ loc, - qualification$1 + t_1 ]; + _t = t$1; continue ; }; } -function raw_generic_with_identifier(env, id) { - var id_0 = id[0]; - var id_1 = { - TAG: "Unqualified", - _0: id - }; - var id$1 = [ - id_0, - id_1 - ]; - var match = identifier(env, id$1); - var id_loc = match[0]; - var typeParameters = Curry._1(type_parameter_instantiation, env); - var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; +function generic_type_with_identifier(env, id) { + var match = Curry._2(raw_generic_with_identifier, env, id); return [ - loc, + match[0], { - id: match[1], - typeParameters: typeParameters + TAG: "Generic", + _0: match[1] } ]; } -function params(env, allow_default, _require_default, _acc) { - while(true) { - var acc = _acc; - var require_default = _require_default; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var variance; - if (typeof match !== "object") { - switch (match) { - case "T_PLUS" : - token$3(env); - variance = "Plus"; - break; - case "T_MINUS" : - token$3(env); - variance = "Minus"; - break; - default: - variance = undefined; - } - } else { - variance = undefined; - } - var match$1 = Curry._2(Parse.identifier_with_type, env, "StrictParamName"); - var id = match$1[1]; - var loc = match$1[0]; - var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); - var match$3; - if (allow_default) { - var exit = 0; - if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { - token$3(env); - match$3 = [ - union(env), - true - ]; - } else { +function function_param_or_generic_type(env) { + var id = Curry._2(Parse.identifier, undefined, env); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var exit = 0; + if (typeof match !== "object") { + switch (match) { + case "T_PLING" : + case "T_COLON" : + exit = 2; + break; + default: exit = 1; - } - if (exit === 1) { - if (require_default) { - error_at(env, [ - loc, - "MissingTypeParamDefault" - ]); - } - match$3 = [ - undefined, - require_default - ]; - } - - } else { - match$3 = [ - undefined, - false - ]; - } - var param_1 = { - name: id.name, - bound: id.typeAnnotation, - variance: variance, - default: match$3[0] - }; - var param = [ - loc, - param_1 - ]; - var acc$1 = { - hd: param, - tl: acc - }; - var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match$4 !== "object") { - switch (match$4) { - case "T_GREATER_THAN" : - case "T_EOF" : - return List.rev(acc$1); - default: - - } - } - token$4(env, "T_COMMA"); - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_GREATER_THAN") { - return List.rev(acc$1); } - _acc = acc$1; - _require_default = match$3[1]; - continue ; - }; + } else { + exit = 1; + } + switch (exit) { + case 1 : + return { + TAG: "Type", + _0: Curry._2(union_with, env, Curry._2(intersection_with, env, postfix_with(env, generic_type_with_identifier(env, id)))) + }; + case 2 : + var param = function_param_with_id(env, id); + maybe(env, "T_COMMA"); + return { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + + } } -function type_parameter_declaration(allow_default, env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_LESS_THAN") { - return ; - } - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAnnotation"); +function param_list_or_type(env) { + token$4(env, "T_LPAREN"); + var token$5 = Curry._2(Parser_env_Peek.token, undefined, env); + var ret; + var exit = 0; + if (typeof token$5 !== "object") { + switch (token$5) { + case "T_IDENTIFIER" : + ret = function_param_or_generic_type(env); + break; + case "T_RPAREN" : + ret = { + TAG: "ParamList", + _0: [ + undefined, + /* [] */0 + ] + }; + break; + case "T_ELLIPSIS" : + case "T_EOF" : + ret = { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, /* [] */0) + }; + break; + default: + exit = 1; + } + } else { + exit = 1; } - token$4(env, "T_LESS_THAN"); - var params$1 = params(env, allow_default, false, /* [] */0); - var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); - token$4(env, "T_GREATER_THAN"); - return [ - loc, - { - params: params$1 - } + if (exit === 1) { + var match = primitive(token$5); + if (match !== undefined) { + var match$1 = Curry._2(Parser_env_Peek.token, 1, env); + var exit$1 = 0; + if (typeof match$1 !== "object") { + switch (match$1) { + case "T_PLING" : + case "T_COLON" : + exit$1 = 2; + break; + default: + ret = { + TAG: "Type", + _0: union(env) + }; + } + } else { + ret = { + TAG: "Type", + _0: union(env) + }; + } + if (exit$1 === 2) { + var match$2 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var name = match$2[0]; + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + var optional = maybe(env, "T_PLING"); + token$4(env, "T_COLON"); + var typeAnnotation = union(env); + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RPAREN") { + token$4(env, "T_COMMA"); + } + var param_0 = btwn(name[0], typeAnnotation[0]); + var param_1 = { + name: name, + typeAnnotation: typeAnnotation, + optional: optional + }; + var param = [ + param_0, + param_1 ]; + ret = { + TAG: "ParamList", + _0: Curry._2(function_param_list_without_parens, env, { + hd: param, + tl: /* [] */0 + }) + }; + } + + } else { + ret = { + TAG: "Type", + _0: union(env) + }; + } + } + token$4(env, "T_RPAREN"); + return ret; } -function union_with(env, left) { - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_OR") { +function postfix(env) { + var t = primary(env); + return postfix_with(env, t); +} + +function intersection_with(env, left) { + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_AND") { var _acc = { hd: left, tl: /* [] */0 @@ -7389,10 +7223,10 @@ function union_with(env, left) { while(true) { var acc = _acc; var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_BIT_OR") { - token$4(env, "T_BIT_OR"); + if (typeof match !== "object" && match === "T_BIT_AND") { + token$4(env, "T_BIT_AND"); _acc = { - hd: intersection(env), + hd: prefix(env), tl: acc }; continue ; @@ -7401,7 +7235,7 @@ function union_with(env, left) { return [ match$1[0], { - TAG: "Union", + TAG: "Intersection", _0: match$1[1] } ]; @@ -7460,74 +7294,128 @@ function function_param_list_without_parens(env) { }; } -function intersection_with(env, left) { - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_AND") { - var _acc = { - hd: left, - tl: /* [] */0 - }; - while(true) { - var acc = _acc; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object" && match === "T_BIT_AND") { - token$4(env, "T_BIT_AND"); - _acc = { - hd: prefix(env), - tl: acc - }; - continue ; - } - var match$1 = rev_nonempty_acc(acc); - return [ - match$1[0], - { - TAG: "Intersection", - _0: match$1[1] - } - ]; - }; - } else { - return left; - } -} - -function types(env, _acc) { +function params(env, allow_default, _require_default, _acc) { while(true) { var acc = _acc; + var require_default = _require_default; var match = Curry._2(Parser_env_Peek.token, undefined, env); + var variance; if (typeof match !== "object") { switch (match) { - case "T_RBRACKET" : - case "T_EOF" : - return List.rev(acc); + case "T_PLUS" : + token$3(env); + variance = "Plus"; + break; + case "T_MINUS" : + token$3(env); + variance = "Minus"; + break; default: - + variance = undefined; } + } else { + variance = undefined; } - var acc_0 = union(env); - var acc$1 = { - hd: acc_0, - tl: acc - }; - if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RBRACKET") { - token$4(env, "T_COMMA"); - } - _acc = acc$1; - continue ; - }; -} - -function methodish(env, start_loc) { - var typeParameters = Curry._2(type_parameter_declaration, false, env); - var match = function_param_list(env); - token$4(env, "T_COLON"); - var returnType = union(env); - var loc = btwn(start_loc, returnType[0]); - return [ - loc, - { - params: match[1], - returnType: returnType, + var match$1 = Curry._2(Parse.identifier_with_type, env, "StrictParamName"); + var id = match$1[1]; + var loc = match$1[0]; + var match$2 = Curry._2(Parser_env_Peek.token, undefined, env); + var match$3; + if (allow_default) { + var exit = 0; + if (typeof match$2 !== "object" && match$2 === "T_ASSIGN") { + token$3(env); + match$3 = [ + union(env), + true + ]; + } else { + exit = 1; + } + if (exit === 1) { + if (require_default) { + error_at(env, [ + loc, + "MissingTypeParamDefault" + ]); + } + match$3 = [ + undefined, + require_default + ]; + } + + } else { + match$3 = [ + undefined, + false + ]; + } + var param_1 = { + name: id.name, + bound: id.typeAnnotation, + variance: variance, + default: match$3[0] + }; + var param = [ + loc, + param_1 + ]; + var acc$1 = { + hd: param, + tl: acc + }; + var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match$4 !== "object") { + switch (match$4) { + case "T_GREATER_THAN" : + case "T_EOF" : + return List.rev(acc$1); + default: + + } + } + token$4(env, "T_COMMA"); + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_GREATER_THAN") { + return List.rev(acc$1); + } + _acc = acc$1; + _require_default = match$3[1]; + continue ; + }; +} + +function type_parameter_declaration(allow_default, env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_LESS_THAN") { + return ; + } + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAnnotation"); + } + token$4(env, "T_LESS_THAN"); + var params$1 = params(env, allow_default, false, /* [] */0); + var loc = btwn(start_loc, Curry._2(Parser_env_Peek.loc, undefined, env)); + token$4(env, "T_GREATER_THAN"); + return [ + loc, + { + params: params$1 + } + ]; +} + +function methodish(env, start_loc) { + var typeParameters = Curry._2(type_parameter_declaration, false, env); + var match = function_param_list(env); + token$4(env, "T_COLON"); + var returnType = union(env); + var loc = btwn(start_loc, returnType[0]); + return [ + loc, + { + params: match[1], + returnType: returnType, rest: match[0], typeParameters: typeParameters } @@ -7771,6 +7659,32 @@ function _object(allow_staticOpt, env) { ]; } +function types(env, _acc) { + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "object") { + switch (match) { + case "T_RBRACKET" : + case "T_EOF" : + return List.rev(acc); + default: + + } + } + var acc_0 = union(env); + var acc$1 = { + hd: acc_0, + tl: acc + }; + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_RBRACKET") { + token$4(env, "T_COMMA"); + } + _acc = acc$1; + continue ; + }; +} + function params$1(env, _acc) { while(true) { var acc = _acc; @@ -7814,6 +7728,92 @@ function type_parameter_instantiation(env) { ]; } +function identifier(env, _param) { + while(true) { + var param = _param; + var qualification = param[1]; + var q_loc = param[0]; + if (Curry._2(Parser_env_Peek.token, undefined, env) !== "T_PERIOD") { + return [ + q_loc, + qualification + ]; + } + token$4(env, "T_PERIOD"); + var id = Curry._2(Parse.identifier, undefined, env); + var loc = btwn(q_loc, id[0]); + var qualification$1 = { + TAG: "Qualified", + _0: [ + loc, + { + qualification: qualification, + id: id + } + ] + }; + _param = [ + loc, + qualification$1 + ]; + continue ; + }; +} + +function raw_generic_with_identifier(env, id) { + var id_0 = id[0]; + var id_1 = { + TAG: "Unqualified", + _0: id + }; + var id$1 = [ + id_0, + id_1 + ]; + var match = identifier(env, id$1); + var id_loc = match[0]; + var typeParameters = Curry._1(type_parameter_instantiation, env); + var loc = typeParameters !== undefined ? btwn(id_loc, typeParameters[0]) : id_loc; + return [ + loc, + { + id: match[1], + typeParameters: typeParameters + } + ]; +} + +function union_with(env, left) { + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_BIT_OR") { + var _acc = { + hd: left, + tl: /* [] */0 + }; + while(true) { + var acc = _acc; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "object" && match === "T_BIT_OR") { + token$4(env, "T_BIT_OR"); + _acc = { + hd: intersection(env), + tl: acc + }; + continue ; + } + var match$1 = rev_nonempty_acc(acc); + return [ + match$1[0], + { + TAG: "Union", + _0: match$1[1] + } + ]; + }; + } else { + return left; + } +} + var _type = union; function annotation(env) { @@ -11345,220 +11345,6 @@ function class_expression(env) { ]; } -function declare_function(env, start_loc) { - token$4(env, "T_FUNCTION"); - var id = Curry._2(Parse.identifier, undefined, env); - var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration$1, env); - var match = wrap(function_param_list, env); - token$4(env, "T_COLON"); - var returnType = wrap(_type, env); - var end_loc = returnType[0]; - var loc = btwn(start_sig_loc, end_loc); - var value_1 = { - TAG: "Function", - _0: { - params: match[1], - returnType: returnType, - rest: match[0], - typeParameters: typeParameters - } - }; - var value = [ - loc, - value_1 - ]; - var typeAnnotation = [ - loc, - value - ]; - var init = id[1]; - var id_0 = btwn(id[0], end_loc); - var id_1 = { - name: init.name, - typeAnnotation: typeAnnotation, - optional: init.optional - }; - var id$1 = [ - id_0, - id_1 - ]; - var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; - var predicate = Curry._1(Parse.predicate, env); - semicolon(env); - var loc$1 = btwn(start_loc, end_loc$2); - return [ - loc$1, - { - id: id$1, - predicate: predicate - } - ]; -} - -function export_specifiers_and_errs(env, _specifiers, _errs) { - while(true) { - var errs = _errs; - var specifiers = _specifiers; - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { - switch (match) { - case "T_RCURLY" : - case "T_EOF" : - return [ - List.rev(specifiers), - List.rev(errs) - ]; - default: - - } - } - var match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var id = match$1[0]; - var match$2; - if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { - contextual(env, "as"); - var match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); - var name = match$3[0]; - record_export(env, [ - name[0], - extract_ident_name(name) - ]); - match$2 = [ - name, - undefined, - name[0] - ]; - } else { - var loc = id[0]; - record_export(env, [ - loc, - extract_ident_name(id) - ]); - match$2 = [ - undefined, - match$1[1], - loc - ]; - } - var err = match$2[1]; - var loc$1 = btwn(id[0], match$2[2]); - var specifier_1 = { - id: id, - name: match$2[0] - }; - var specifier = [ - loc$1, - specifier_1 - ]; - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_COMMA") { - token$4(env, "T_COMMA"); - } - var errs$1 = err !== undefined ? ({ - hd: err, - tl: errs - }) : errs; - _errs = errs$1; - _specifiers = { - hd: specifier, - tl: specifiers - }; - continue ; - }; -} - -function declare_var(env, start_loc) { - token$4(env, "T_VAR"); - var id = Curry._2(Parse.identifier_with_type, env, "StrictVarName"); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : id[0]; - var loc$1 = btwn(start_loc, end_loc); - semicolon(env); - return [ - loc$1, - { - id: id - } - ]; -} - -function export_source(env) { - contextual(env, "from"); - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match === "object" && match.TAG === "T_STRING") { - var match$1 = match._0; - var octal = match$1[3]; - var raw = match$1[2]; - var value = match$1[1]; - var loc = match$1[0]; - if (octal) { - strict_error(env, "StrictOctalLiteral"); - } - token$4(env, { - TAG: "T_STRING", - _0: [ - loc, - value, - raw, - octal - ] - }); - var value$1 = { - TAG: "String", - _0: value - }; - return [ - loc, - { - value: value$1, - raw: raw - } - ]; - } - var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); - var value$2 = { - TAG: "String", - _0: raw$1 - }; - var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); - var ret_1 = { - value: value$2, - raw: raw$1 - }; - var ret = [ - ret_0, - ret_1 - ]; - error_unexpected(env); - return ret; -} - -function type_alias_helper(env) { - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - if (!env.parse_options.types) { - error(env, "UnexpectedTypeAlias"); - } - token$4(env, "T_TYPE"); - push_lex_mode(env, "TYPE"); - var id = Curry._2(Parse.identifier, undefined, env); - var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); - token$4(env, "T_ASSIGN"); - var right = wrap(_type, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; - semicolon(env); - pop_lex_mode(env); - return [ - btwn(start_loc, end_loc$1), - { - id: id, - typeParameters: typeParameters, - right: right - } - ]; -} - function declare(in_moduleOpt, env) { var in_module = in_moduleOpt !== undefined ? in_moduleOpt : false; if (!env.parse_options.types) { @@ -11705,58 +11491,224 @@ function declare(in_moduleOpt, env) { } } -function expression(env) { - var expression$1 = Curry._1(Parse.expression, env); - var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc = loc !== undefined ? loc : expression$1[0]; +function type_alias_helper(env) { + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + if (!env.parse_options.types) { + error(env, "UnexpectedTypeAlias"); + } + token$4(env, "T_TYPE"); + push_lex_mode(env, "TYPE"); + var id = Curry._2(Parse.identifier, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration_with_defaults, env); + token$4(env, "T_ASSIGN"); + var right = wrap(_type, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : right[0]; semicolon(env); + pop_lex_mode(env); return [ - btwn(expression$1[0], end_loc), + btwn(start_loc, end_loc$1), { - TAG: "Expression", - _0: { - expression: expression$1 - } + id: id, + typeParameters: typeParameters, + right: right } ]; } -function $$interface(env) { - if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { - return expression(env); +function export_source(env) { + contextual(env, "from"); + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match === "object" && match.TAG === "T_STRING") { + var match$1 = match._0; + var octal = match$1[3]; + var raw = match$1[2]; + var value = match$1[1]; + var loc = match$1[0]; + if (octal) { + strict_error(env, "StrictOctalLiteral"); + } + token$4(env, { + TAG: "T_STRING", + _0: [ + loc, + value, + raw, + octal + ] + }); + var value$1 = { + TAG: "String", + _0: value + }; + return [ + loc, + { + value: value$1, + raw: raw + } + ]; } - var match = Curry._1(interface_helper, env); - return [ - match[0], - { - TAG: "InterfaceDeclaration", - _0: match[1] - } - ]; + var raw$1 = Curry._2(Parser_env_Peek.value, undefined, env); + var value$2 = { + TAG: "String", + _0: raw$1 + }; + var ret_0 = Curry._2(Parser_env_Peek.loc, undefined, env); + var ret_1 = { + value: value$2, + raw: raw$1 + }; + var ret = [ + ret_0, + ret_1 + ]; + error_unexpected(env); + return ret; } -function declare_var_statement(env, start_loc) { - var match = declare_var(env, start_loc); +function declare_var(env, start_loc) { + token$4(env, "T_VAR"); + var id = Curry._2(Parse.identifier_with_type, env, "StrictVarName"); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : id[0]; + var loc$1 = btwn(start_loc, end_loc); + semicolon(env); return [ - match[0], + loc$1, { - TAG: "DeclareVariable", - _0: match[1] + id: id } ]; } -function declare_function_statement(env, start_loc) { - var match = declare_function(env, start_loc); +function export_specifiers_and_errs(env, _specifiers, _errs) { + while(true) { + var errs = _errs; + var specifiers = _specifiers; + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "object") { + switch (match) { + case "T_RCURLY" : + case "T_EOF" : + return [ + List.rev(specifiers), + List.rev(errs) + ]; + default: + + } + } + var match$1 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var id = match$1[0]; + var match$2; + if (Curry._2(Parser_env_Peek.value, undefined, env) === "as") { + contextual(env, "as"); + var match$3 = Curry._1(Parse.identifier_or_reserved_keyword, env); + var name = match$3[0]; + record_export(env, [ + name[0], + extract_ident_name(name) + ]); + match$2 = [ + name, + undefined, + name[0] + ]; + } else { + var loc = id[0]; + record_export(env, [ + loc, + extract_ident_name(id) + ]); + match$2 = [ + undefined, + match$1[1], + loc + ]; + } + var err = match$2[1]; + var loc$1 = btwn(id[0], match$2[2]); + var specifier_1 = { + id: id, + name: match$2[0] + }; + var specifier = [ + loc$1, + specifier_1 + ]; + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_COMMA") { + token$4(env, "T_COMMA"); + } + var errs$1 = err !== undefined ? ({ + hd: err, + tl: errs + }) : errs; + _errs = errs$1; + _specifiers = { + hd: specifier, + tl: specifiers + }; + continue ; + }; +} + +function declare_function(env, start_loc) { + token$4(env, "T_FUNCTION"); + var id = Curry._2(Parse.identifier, undefined, env); + var start_sig_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + var typeParameters = Curry._1(type_parameter_declaration$1, env); + var match = wrap(function_param_list, env); + token$4(env, "T_COLON"); + var returnType = wrap(_type, env); + var end_loc = returnType[0]; + var loc = btwn(start_sig_loc, end_loc); + var value_1 = { + TAG: "Function", + _0: { + params: match[1], + returnType: returnType, + rest: match[0], + typeParameters: typeParameters + } + }; + var value = [ + loc, + value_1 + ]; + var typeAnnotation = [ + loc, + value + ]; + var init = id[1]; + var id_0 = btwn(id[0], end_loc); + var id_1 = { + name: init.name, + typeAnnotation: typeAnnotation, + optional: init.optional + }; + var id$1 = [ + id_0, + id_1 + ]; + var end_loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$2 = end_loc$1 !== undefined ? end_loc$1 : end_loc; + var predicate = Curry._1(Parse.predicate, env); + semicolon(env); + var loc$1 = btwn(start_loc, end_loc$2); return [ - match[0], + loc$1, { - TAG: "DeclareFunction", - _0: match[1] + id: id$1, + predicate: predicate } ]; } +function extract_ident_name(param) { + return param[1].name; +} + function type_alias(env) { if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { return Curry._1(Parse.statement, env); @@ -11771,6 +11723,31 @@ function type_alias(env) { ]; } +function $$interface(env) { + if (!Curry._2(Parser_env_Peek.is_identifier, 1, env)) { + return expression(env); + } + var match = Curry._1(interface_helper, env); + return [ + match[0], + { + TAG: "InterfaceDeclaration", + _0: match[1] + } + ]; +} + +function declare_var_statement(env, start_loc) { + var match = declare_var(env, start_loc); + return [ + match[0], + { + TAG: "DeclareVariable", + _0: match[1] + } + ]; +} + function declare_export_declaration(allow_export_typeOpt, env) { var allow_export_type = allow_export_typeOpt !== undefined ? allow_export_typeOpt : false; if (!env.parse_options.types) { @@ -12068,8 +12045,31 @@ function declare_export_declaration(allow_export_typeOpt, env) { } } -function extract_ident_name(param) { - return param[1].name; +function declare_function_statement(env, start_loc) { + var match = declare_function(env, start_loc); + return [ + match[0], + { + TAG: "DeclareFunction", + _0: match[1] + } + ]; +} + +function expression(env) { + var expression$1 = Curry._1(Parse.expression, env); + var loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc = loc !== undefined ? loc : expression$1[0]; + semicolon(env); + return [ + btwn(expression$1[0], end_loc), + { + TAG: "Expression", + _0: { + expression: expression$1 + } + } + ]; } function supers(env, _acc) { @@ -13511,37 +13511,122 @@ function element_without_lt(env, start_loc) { ]; } -function statement(env) { - while(true) { - var match = Curry._2(Parser_env_Peek.token, undefined, env); - var exit = 0; - if (typeof match !== "object") { - switch (match) { - case "T_LCURLY" : - var match$1 = Curry._1(Parse.block_body, env); +function statement_list_item(decoratorsOpt, env) { + var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; + if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { + error_on_decorators(env)(decorators); + } + var match = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof match !== "object") { + switch (match) { + case "T_CONST" : + return var_or_const(env); + case "T_LET" : + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_LET"); + if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LPAREN") { + token$4(env, "T_LPAREN"); + var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var head = List.map((function (param) { + var match = param[1]; + return { + id: match.id, + init: match.init + }; + }), match$1[1]); + token$4(env, "T_RPAREN"); + var body = Curry._1(Parse.statement, env); + var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; + semicolon(env); + List.iter((function (param) { + return error_at(env, param); + }), match$1[2]); return [ - match$1[0], + btwn(start_loc, end_loc$1), { - TAG: "Block", - _0: match$1[1] + TAG: "Let", + _0: { + head: head, + body: body + } } ]; - case "T_SEMICOLON" : - var loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_SEMICOLON"); - return [ - loc, - "Empty" - ]; - case "T_IF" : - return _if(env); - case "T_RETURN" : - if (!env.in_function) { - error(env, "IllegalReturn"); - } - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_RETURN"); - var argument = Curry._2(Parser_env_Peek.token, undefined, env) === "T_SEMICOLON" || Curry._1(Parser_env_Peek.is_implicit_semicolon, env) ? undefined : Curry._1(Parse.expression, env); + } + var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); + var declaration = { + TAG: "VariableDeclaration", + _0: { + declarations: match$2[1], + kind: "Let" + } + }; + var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); + var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; + semicolon(env); + List.iter((function (param) { + return error_at(env, param); + }), match$2[2]); + return [ + btwn(start_loc, end_loc$3), + declaration + ]; + default: + + } + } + if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { + return _function(env); + } + if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { + return class_declaration$1(env, decorators); + } + if (typeof match === "object") { + return statement(env); + } + switch (match) { + case "T_INTERFACE" : + return $$interface(env); + case "T_DECLARE" : + return declare(undefined, env); + case "T_TYPE" : + return type_alias(env); + default: + return statement(env); + } +} + +function statement(env) { + while(true) { + var match = Curry._2(Parser_env_Peek.token, undefined, env); + var exit = 0; + if (typeof match !== "object") { + switch (match) { + case "T_LCURLY" : + var match$1 = Curry._1(Parse.block_body, env); + return [ + match$1[0], + { + TAG: "Block", + _0: match$1[1] + } + ]; + case "T_SEMICOLON" : + var loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_SEMICOLON"); + return [ + loc, + "Empty" + ]; + case "T_IF" : + return _if(env); + case "T_RETURN" : + if (!env.in_function) { + error(env, "IllegalReturn"); + } + var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); + token$4(env, "T_RETURN"); + var argument = Curry._2(Parser_env_Peek.token, undefined, env) === "T_SEMICOLON" || Curry._1(Parser_env_Peek.is_implicit_semicolon, env) ? undefined : Curry._1(Parse.expression, env); var loc$1 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); var end_loc = loc$1 !== undefined ? loc$1 : ( argument !== undefined ? argument[0] : start_loc @@ -14614,94 +14699,26 @@ function module_item(env) { } } -function statement_list_item(decoratorsOpt, env) { - var decorators = decoratorsOpt !== undefined ? decoratorsOpt : /* [] */0; - if (!Curry._2(Parser_env_Peek.is_class, undefined, env)) { - error_on_decorators(env)(decorators); - } - var match = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof match !== "object") { - switch (match) { - case "T_CONST" : - return var_or_const(env); - case "T_LET" : - var start_loc = Curry._2(Parser_env_Peek.loc, undefined, env); - token$4(env, "T_LET"); - if (Curry._2(Parser_env_Peek.token, undefined, env) === "T_LPAREN") { - token$4(env, "T_LPAREN"); - var match$1 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var head = List.map((function (param) { - var match = param[1]; - return { - id: match.id, - init: match.init - }; - }), match$1[1]); - token$4(env, "T_RPAREN"); - var body = Curry._1(Parse.statement, env); - var end_loc = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$1 = end_loc !== undefined ? end_loc : match$1[0]; - semicolon(env); - List.iter((function (param) { - return error_at(env, param); - }), match$1[2]); - return [ - btwn(start_loc, end_loc$1), - { - TAG: "Let", - _0: { - head: head, - body: body - } - } - ]; - } - var match$2 = helper(with_no_let(true, env), /* [] */0, /* [] */0); - var declaration = { - TAG: "VariableDeclaration", - _0: { - declarations: match$2[1], - kind: "Let" - } - }; - var end_loc$2 = Curry._2(Parser_env_Peek.semicolon_loc, undefined, env); - var end_loc$3 = end_loc$2 !== undefined ? end_loc$2 : match$2[0]; - semicolon(env); - List.iter((function (param) { - return error_at(env, param); - }), match$2[2]); - return [ - btwn(start_loc, end_loc$3), - declaration - ]; - default: - +function statement_list(term_fn, env) { + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var t = Curry._2(Parser_env_Peek.token, undefined, env); + if (typeof t !== "object" && t === "T_EOF") { + return List.rev(acc); } - } - if (Curry._2(Parser_env_Peek.is_function, undefined, env)) { - return _function(env); - } - if (Curry._2(Parser_env_Peek.is_class, undefined, env)) { - return class_declaration$1(env, decorators); - } - if (typeof match === "object") { - return statement(env); - } - switch (match) { - case "T_INTERFACE" : - return $$interface(env); - case "T_DECLARE" : - return declare(undefined, env); - case "T_TYPE" : - return type_alias(env); - default: - return statement(env); - } + if (Curry._1(term_fn, t)) { + return List.rev(acc); + } + _acc = { + hd: statement_list_item(undefined, env), + tl: acc + }; + continue ; + }; } -var class_declaration$1 = class_declaration; - -function statement_list(_env, term_fn, item_fn, _param) { +function statement_list$1(_env, term_fn, item_fn, _param) { while(true) { var param = _param; var env = _env; @@ -14796,7 +14813,7 @@ function statement_list(_env, term_fn, item_fn, _param) { } function directives(env, term_fn, item_fn) { - var match = statement_list(env, term_fn, item_fn, [ + var match = statement_list$1(env, term_fn, item_fn, [ /* [] */0, /* [] */0 ]); @@ -14826,6 +14843,8 @@ function directives(env, term_fn, item_fn) { ]; } +var class_declaration$1 = class_declaration; + function module_body(term_fn, env) { var _acc = /* [] */0; while(true) { @@ -14845,54 +14864,6 @@ function module_body(term_fn, env) { }; } -function statement_list$1(term_fn, env) { - var _acc = /* [] */0; - while(true) { - var acc = _acc; - var t = Curry._2(Parser_env_Peek.token, undefined, env); - if (typeof t !== "object" && t === "T_EOF") { - return List.rev(acc); - } - if (Curry._1(term_fn, t)) { - return List.rev(acc); - } - _acc = { - hd: statement_list_item(undefined, env), - tl: acc - }; - continue ; - }; -} - -function statement_list_with_directives(term_fn, env) { - var match = Curry._3(directives, env, term_fn, (function (eta) { - return statement_list_item(undefined, eta); - })); - var env$1 = match[0]; - var stmts = Curry._2(statement_list$1, term_fn, env$1); - var stmts$1 = List.fold_left((function (acc, stmt) { - return { - hd: stmt, - tl: acc - }; - }), stmts, match[1]); - return [ - stmts$1, - env$1.in_strict_mode - ]; -} - -function module_body_with_directives(env, term_fn) { - var match = Curry._3(directives, env, term_fn, module_item); - var stmts = Curry._2(module_body, term_fn, match[0]); - return List.fold_left((function (acc, stmt) { - return { - hd: stmt, - tl: acc - }; - }), stmts, match[1]); -} - function identifier$2(restricted_error, env) { var loc = Curry._2(Parser_env_Peek.loc, undefined, env); var name = Curry._2(Parser_env_Peek.value, undefined, env); @@ -14947,6 +14918,35 @@ function identifier$2(restricted_error, env) { ]; } +function module_body_with_directives(env, term_fn) { + var match = Curry._3(directives, env, term_fn, module_item); + var stmts = Curry._2(module_body, term_fn, match[0]); + return List.fold_left((function (acc, stmt) { + return { + hd: stmt, + tl: acc + }; + }), stmts, match[1]); +} + +function statement_list_with_directives(term_fn, env) { + var match = Curry._3(directives, env, term_fn, (function (eta) { + return statement_list_item(undefined, eta); + })); + var env$1 = match[0]; + var stmts = Curry._2(statement_list, term_fn, env$1); + var stmts$1 = List.fold_left((function (acc, stmt) { + return { + hd: stmt, + tl: acc + }; + }), stmts, match[1]); + return [ + stmts$1, + env$1.in_strict_mode + ]; +} + function program(env) { var stmts = module_body_with_directives(env, (function (param) { return false; @@ -15027,7 +15027,7 @@ function block_body(env) { var term_fn = function (t) { return t === "T_RCURLY"; }; - var body = Curry._2(statement_list$1, term_fn, env); + var body = Curry._2(statement_list, term_fn, env); var end_loc = Curry._2(Parser_env_Peek.loc, undefined, env); token$4(env, "T_RCURLY"); return [ @@ -15181,7 +15181,7 @@ Caml_module.update_mod({ program: program, statement: statement, statement_list_item: statement_list_item, - statement_list: statement_list$1, + statement_list: statement_list, statement_list_with_directives: statement_list_with_directives, module_body: module_body, expression: expression$1, @@ -15496,84 +15496,6 @@ function parse(content, options) { } } }; - var jsx_member_expression = function (param) { - var member_expression = param[1]; - var id = member_expression._object; - var _object; - _object = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ - [ - "object", - _object - ], - [ - "property", - jsx_identifier(member_expression.property) - ] - ]); - }; - var jsx_namespaced_name = function (param) { - var namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ - [ - "namespace", - jsx_identifier(namespaced_name.namespace) - ], - [ - "name", - jsx_identifier(namespaced_name.name) - ] - ]); - }; - var jsx_identifier = function (param) { - return node("JSXIdentifier", param[0], [[ - "name", - string(param[1].name) - ]]); - }; - var jsx_element = function (param) { - var element = param[1]; - return node("JSXElement", param[0], [ - [ - "openingElement", - jsx_opening(element.openingElement) - ], - [ - "closingElement", - option(jsx_closing, element.closingElement) - ], - [ - "children", - array_of_list(jsx_child, element.children) - ] - ]); - }; - var jsx_expression_container = function (param) { - var expr = param[1].expression; - var expression$1; - expression$1 = expr.TAG === "Expression" ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 - ]]); - }; - var identifier = function (param) { - var id = param[1]; - return node("Identifier", param[0], [ - [ - "name", - string(id.name) - ], - [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) - ], - [ - "optional", - bool(id.optional) - ] - ]); - }; var expression = function (param) { var arr = param[1]; var loc = param[0]; @@ -15857,7 +15779,8 @@ function parse(content, options) { case "Update" : var update = arr._0; var match$4 = update.operator; - var operator$3 = match$4 ? "--" : "++"; + var operator$3; + operator$3 = match$4 === "Increment" ? "++" : "--"; return node("UpdateExpression", loc, [ [ "operator", @@ -15875,7 +15798,8 @@ function parse(content, options) { case "Logical" : var logical = arr._0; var match$5 = logical.operator; - var operator$4 = match$5 ? "&&" : "||"; + var operator$4; + operator$4 = match$5 === "Or" ? "||" : "&&"; return node("LogicalExpression", loc, [ [ "operator", @@ -16081,744 +16005,284 @@ function parse(content, options) { } }; - var object_type_call_property = function (param) { - var callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ - [ - "value", - function_type(callProperty.value) - ], - [ - "static", - bool(callProperty.static) - ] - ]); - }; - var object_type_property = function (param) { - var prop = param[1]; - var lit = prop.key; - var key; - switch (lit.TAG) { - case "Literal" : - key = literal(lit._0); - break; - case "Identifier" : - key = identifier(lit._0); - break; - case "Computed" : - throw { - RE_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; - - } - return node("ObjectTypeProperty", param[0], [ + var identifier = function (param) { + var id = param[1]; + return node("Identifier", param[0], [ [ - "key", - key + "name", + string(id.name) ], [ - "value", - _type(prop.value) + "typeAnnotation", + option(type_annotation, id.typeAnnotation) ], [ "optional", - bool(prop.optional) - ], - [ - "static", - bool(prop.static) - ] - ]); - }; - var object_type_indexer = function (param) { - var indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ - [ - "id", - identifier(indexer.id) - ], - [ - "key", - _type(indexer.key) - ], - [ - "value", - _type(indexer.value) - ], - [ - "static", - bool(indexer.static) - ] - ]); - }; - var $$case = function (param) { - var c = param[1]; - return node("SwitchCase", param[0], [ - [ - "test", - option(expression, c.test) - ], - [ - "consequent", - array_of_list(statement, c.consequent) - ] - ]); - }; - var variable_declaration = function (param) { - var $$var = param[1]; - var match = $$var.kind; - var kind; - switch (match) { - case "Var" : - kind = "var"; - break; - case "Let" : - kind = "let"; - break; - case "Const" : - kind = "const"; - break; - - } - return node("VariableDeclaration", param[0], [ - [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) - ], - [ - "kind", - string(kind) + bool(id.optional) ] ]); }; - var interface_declaration = function (param) { - var i = param[1]; - return node("InterfaceDeclaration", param[0], [ - [ - "id", - identifier(i.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, i.typeParameters) - ], - [ - "body", - object_type(i.body) - ], - [ - "extends", - array_of_list(interface_extends, i.extends) - ] - ]); + var type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); }; - var statement = function (param) { - var b = param[1]; + var literal = function (param) { + var lit = param[1]; + var raw = lit.raw; + var value = lit.value; var loc = param[0]; - if (typeof b !== "object") { - if (b === "Empty") { - return node("EmptyStatement", loc, []); - } else { - return node("DebuggerStatement", loc, []); + var value_; + if (typeof value !== "object") { + value_ = $$null; + } else { + switch (value.TAG) { + case "String" : + value_ = string(value._0); + break; + case "Boolean" : + value_ = bool(value._0); + break; + case "Number" : + value_ = number$1(value._0); + break; + case "RegExp" : + var match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + } } - switch (b.TAG) { - case "Block" : - return block([ - loc, - b._0 - ]); - case "Expression" : - return node("ExpressionStatement", loc, [[ - "expression", - expression(b._0.expression) - ]]); - case "If" : - var _if = b._0; - return node("IfStatement", loc, [ - [ - "test", - expression(_if.test) - ], - [ - "consequent", - statement(_if.consequent) - ], - [ - "alternate", - option(statement, _if.alternate) - ] - ]); - case "Labeled" : - var labeled = b._0; - return node("LabeledStatement", loc, [ - [ - "label", - identifier(labeled.label) - ], - [ - "body", - statement(labeled.body) - ] - ]); - case "Break" : - return node("BreakStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case "Continue" : - return node("ContinueStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case "With" : - var _with = b._0; - return node("WithStatement", loc, [ - [ - "object", - expression(_with._object) - ], - [ - "body", - statement(_with.body) - ] - ]); - case "TypeAlias" : - return type_alias([ - loc, - b._0 - ]); - case "Switch" : - var $$switch = b._0; - return node("SwitchStatement", loc, [ - [ - "discriminant", - expression($$switch.discriminant) - ], - [ - "cases", - array_of_list($$case, $$switch.cases) - ], - [ - "lexical", - bool($$switch.lexical) - ] - ]); - case "Return" : - return node("ReturnStatement", loc, [[ - "argument", - option(expression, b._0.argument) - ]]); - case "Throw" : - return node("ThrowStatement", loc, [[ - "argument", - expression(b._0.argument) - ]]); - case "Try" : - var _try = b._0; - return node("TryStatement", loc, [ - [ - "block", - block(_try.block) - ], - [ - "handler", - option($$catch, _try.handler) - ], - [ - "guardedHandlers", - array_of_list($$catch, _try.guardedHandlers) - ], - [ - "finalizer", - option(block, _try.finalizer) - ] - ]); - case "While" : - var _while = b._0; - return node("WhileStatement", loc, [ - [ - "test", - expression(_while.test) - ], - [ - "body", - statement(_while.body) - ] - ]); - case "DoWhile" : - var dowhile = b._0; - return node("DoWhileStatement", loc, [ - [ - "body", - statement(dowhile.body) - ], - [ - "test", - expression(dowhile.test) - ] - ]); - case "For" : - var _for = b._0; - var init = function (init$1) { - if (init$1.TAG === "InitDeclaration") { - return variable_declaration(init$1._0); - } else { - return expression(init$1._0); - } - }; - return node("ForStatement", loc, [ - [ - "init", - option(init, _for.init) - ], - [ - "test", - option(expression, _for.test) - ], + var props; + var exit = 0; + if (typeof value !== "object" || value.TAG !== "RegExp") { + exit = 1; + } else { + var match$1 = value._0; + var regex = obj([ + [ + "pattern", + string(match$1.pattern) + ], + [ + "flags", + string(match$1.flags) + ] + ]); + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ], + [ + "regex", + regex + ] + ]; + } + if (exit === 1) { + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ] + ]; + } + return node("Literal", loc, props); + }; + var pattern = function (param) { + var obj = param[1]; + var loc = param[0]; + switch (obj.TAG) { + case "Object" : + var obj$1 = obj._0; + return node("ObjectPattern", loc, [ [ - "update", - option(expression, _for.update) + "properties", + array_of_list(object_pattern_property, obj$1.properties) ], [ - "body", - statement(_for.body) + "typeAnnotation", + option(type_annotation, obj$1.typeAnnotation) ] ]); - case "ForIn" : - var forin = b._0; - var left = forin.left; - var left$1; - left$1 = left.TAG === "LeftDeclaration" ? variable_declaration(left._0) : expression(left._0); - return node("ForInStatement", loc, [ - [ - "left", - left$1 - ], - [ - "right", - expression(forin.right) - ], + case "Array" : + var arr = obj._0; + return node("ArrayPattern", loc, [ [ - "body", - statement(forin.body) + "elements", + array_of_list((function (param) { + return option(array_pattern_element, param); + }), arr.elements) ], [ - "each", - bool(forin.each) + "typeAnnotation", + option(type_annotation, arr.typeAnnotation) ] ]); - case "ForOf" : - var forof = b._0; - var left$2 = forof.left; - var left$3; - left$3 = left$2.TAG === "LeftDeclaration" ? variable_declaration(left$2._0) : expression(left$2._0); - return node("ForOfStatement", loc, [ + case "Assignment" : + var match = obj._0; + return node("AssignmentPattern", loc, [ [ "left", - left$3 + pattern(match.left) ], [ "right", - expression(forof.right) - ], - [ - "body", - statement(forof.body) - ] - ]); - case "Let" : - var _let = b._0; - return node("LetStatement", loc, [ - [ - "head", - array_of_list(let_assignment, _let.head) - ], - [ - "body", - statement(_let.body) + expression(match.right) ] ]); - case "FunctionDeclaration" : - var fn = b._0; - var id = fn.id; - var match = id !== undefined ? [ - "FunctionDeclaration", - identifier(id) - ] : [ - "FunctionExpression", - $$null + case "Identifier" : + return identifier(obj._0); + case "Expression" : + return expression(obj._0); + + } + }; + var object_pattern_property = function (param) { + if (param.TAG === "Property") { + var match = param._0; + var prop = match[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG) { + case "Literal" : + match$1 = [ + literal(lit._0), + false ]; - var b$1 = fn.body; - var body; - body = b$1.TAG === "BodyBlock" ? block(b$1._0) : expression(b$1._0); - return node(match[0], loc, [ - [ - "id", - match[1] - ], - [ - "params", - array_of_list(pattern, fn.params) - ], - [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), fn.defaults) - ], - [ - "rest", - option(identifier, fn.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(fn.async) - ], - [ - "generator", - bool(fn.generator) - ], - [ - "expression", - bool(fn.expression) - ], - [ - "returnType", - option(type_annotation, fn.returnType) - ], - [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) - ] - ]); - case "VariableDeclaration" : - return variable_declaration([ - loc, - b._0 - ]); - case "ClassDeclaration" : - var param$1 = [ - loc, - b._0 - ]; - var c = param$1[1]; - var id$1 = c.id; - var match$1 = id$1 !== undefined ? [ - "ClassDeclaration", - identifier(id$1) - ] : [ - "ClassExpression", - $$null + break; + case "Identifier" : + match$1 = [ + identifier(lit._0), + false ]; - return node(match$1[0], param$1[0], [ - [ - "id", - match$1[1] - ], - [ - "body", - class_body(c.body) - ], - [ - "superClass", - option(expression, c.superClass) - ], - [ - "typeParameters", - option(type_parameter_declaration, c.typeParameters) - ], - [ - "superTypeParameters", - option(type_parameter_instantiation, c.superTypeParameters) - ], - [ - "implements", - array_of_list(class_implements, c.implements) - ], - [ - "decorators", - array_of_list(expression, c.classDecorators) - ] - ]); - case "InterfaceDeclaration" : - return interface_declaration([ - loc, - b._0 - ]); - case "DeclareVariable" : - return declare_variable([ - loc, - b._0 - ]); - case "DeclareFunction" : - return declare_function([ - loc, - b._0 - ]); - case "DeclareClass" : - return declare_class([ - loc, - b._0 - ]); - case "DeclareModule" : - var m = b._0; - var lit = m.id; - var id$2; - id$2 = lit.TAG === "Identifier" ? identifier(lit._0) : literal(lit._0); - var match$2 = m.kind; - var tmp; - tmp = match$2.TAG === "CommonJS" ? string("CommonJS") : string("ES"); - return node("DeclareModule", loc, [ - [ - "id", - id$2 - ], - [ - "body", - block(m.body) - ], - [ - "kind", - tmp - ] - ]); - case "DeclareModuleExports" : - return node("DeclareModuleExports", loc, [[ - "typeAnnotation", - type_annotation(b._0) - ]]); - case "DeclareExportDeclaration" : - var $$export = b._0; - var match$3 = $$export.declaration; - var declaration; - if (match$3 !== undefined) { - switch (match$3.TAG) { - case "Variable" : - declaration = declare_variable(match$3._0); - break; - case "Function" : - declaration = declare_function(match$3._0); - break; - case "Class" : - declaration = declare_class(match$3._0); - break; - case "DefaultType" : - declaration = _type(match$3._0); - break; - case "NamedType" : - declaration = type_alias(match$3._0); - break; - case "Interface" : - declaration = interface_declaration(match$3._0); - break; - - } - } else { - declaration = $$null; - } - return node("DeclareExportDeclaration", loc, [ - [ - "default", - bool($$export.default) - ], - [ - "declaration", - declaration - ], - [ - "specifiers", - export_specifiers($$export.specifiers) - ], - [ - "source", - option(literal, $$export.source) - ] - ]); - case "ExportDeclaration" : - var $$export$1 = b._0; - var match$4 = $$export$1.declaration; - var declaration$1 = match$4 !== undefined ? ( - match$4.TAG === "Declaration" ? statement(match$4._0) : expression(match$4._0) - ) : $$null; - return node("ExportDeclaration", loc, [ - [ - "default", - bool($$export$1.default) - ], - [ - "declaration", - declaration$1 - ], - [ - "specifiers", - export_specifiers($$export$1.specifiers) - ], - [ - "source", - option(literal, $$export$1.source) - ], - [ - "exportKind", - string($$export$1.exportKind ? "value" : "type") - ] - ]); - case "ImportDeclaration" : - var $$import = b._0; - var specifiers = List.map((function (id) { - switch (id.TAG) { - case "ImportNamedSpecifier" : - var match = id._0; - var local_id = match.local; - var remote_id = match.remote; - var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; - return node("ImportSpecifier", span_loc, [ - [ - "id", - identifier(remote_id) - ], - [ - "name", - option(identifier, local_id) - ] - ]); - case "ImportDefaultSpecifier" : - var id$1 = id._0; - return node("ImportDefaultSpecifier", id$1[0], [[ - "id", - identifier(id$1) - ]]); - case "ImportNamespaceSpecifier" : - var param = id._0; - return node("ImportNamespaceSpecifier", param[0], [[ - "id", - identifier(param[1]) - ]]); - - } - }), $$import.specifiers); - var match$5 = $$import.importKind; - var import_kind; - switch (match$5) { - case "ImportType" : - import_kind = "type"; - break; - case "ImportTypeof" : - import_kind = "typeof"; - break; - case "ImportValue" : - import_kind = "value"; - break; - - } - return node("ImportDeclaration", loc, [ - [ - "specifiers", - array($$Array.of_list(specifiers)) - ], - [ - "source", - literal($$import.source) - ], - [ - "importKind", - string(import_kind) - ] - ]); - + break; + case "Computed" : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + return node("PropertyPattern", match[0], [ + [ + "key", + match$1[0] + ], + [ + "pattern", + pattern(prop.pattern) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "shorthand", + bool(prop.shorthand) + ] + ]); } + var match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ + "argument", + pattern(match$2[1].argument) + ]]); }; - var pattern = function (param) { - var obj = param[1]; - var loc = param[0]; - switch (obj.TAG) { - case "Object" : - var obj$1 = obj._0; - return node("ObjectPattern", loc, [ - [ - "properties", - array_of_list(object_pattern_property, obj$1.properties) - ], - [ - "typeAnnotation", - option(type_annotation, obj$1.typeAnnotation) - ] - ]); - case "Array" : - var arr = obj._0; - return node("ArrayPattern", loc, [ - [ - "elements", - array_of_list((function (param) { - return option(array_pattern_element, param); - }), arr.elements) - ], - [ - "typeAnnotation", - option(type_annotation, arr.typeAnnotation) - ] - ]); - case "Assignment" : - var match = obj._0; - return node("AssignmentPattern", loc, [ - [ - "left", - pattern(match.left) - ], - [ - "right", - expression(match.right) - ] - ]); - case "Identifier" : - return identifier(obj._0); - case "Expression" : - return expression(obj._0); - + var array_pattern_element = function (p) { + if (p.TAG === "Element") { + return pattern(p._0); } - }; - var declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) + var match = p._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) ]]); }; - var export_specifiers = function (param) { - if (param !== undefined) { - if (param.TAG === "ExportSpecifiers") { - return array_of_list(export_specifier, param._0); - } else { - return array([node("ExportBatchSpecifier", param._0, [[ - "name", - option(identifier, param._1) - ]])]); + var object_property = function (param) { + if (param.TAG === "Property") { + var match = param._0; + var prop = match[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG) { + case "Literal" : + match$1 = [ + literal(lit._0), + false + ]; + break; + case "Identifier" : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case "Computed" : + match$1 = [ + expression(lit._0), + true + ]; + break; + } - } else { - return array([]); + var match$2 = prop.kind; + var kind; + switch (match$2) { + case "Init" : + kind = "init"; + break; + case "Get" : + kind = "get"; + break; + case "Set" : + kind = "set"; + break; + + } + return node("Property", match[0], [ + [ + "key", + match$1[0] + ], + [ + "value", + expression(prop.value) + ], + [ + "kind", + string(kind) + ], + [ + "method", + bool(prop._method) + ], + [ + "shorthand", + bool(prop.shorthand) + ], + [ + "computed", + bool(match$1[1]) + ] + ]); } - }; - var type_alias = function (param) { - var alias = param[1]; - return node("TypeAlias", param[0], [ - [ - "id", - identifier(alias.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) - ], - [ - "right", - _type(alias.right) - ] - ]); + var match$3 = param._0; + return node("SpreadProperty", match$3[0], [[ + "argument", + expression(match$3[1].argument) + ]]); }; var let_assignment = function (assignment) { return obj([ @@ -16832,124 +16296,116 @@ function parse(content, options) { ] ]); }; - var block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) + var expression_or_spread = function (expr) { + if (expr.TAG === "Expression") { + return expression(expr._0); + } + var match = expr._0; + return node("SpreadElement", match[0], [[ + "argument", + expression(match[1].argument) ]]); }; - var $$catch = function (param) { - var c = param[1]; - return node("CatchClause", param[0], [ - [ - "param", - pattern(c.param) - ], + var template_literal = function (param) { + var value = param[1]; + return node("TemplateLiteral", param[0], [ [ - "guard", - option(expression, c.guard) + "quasis", + array_of_list(template_element, value.quasis) ], [ - "body", - block(c.body) + "expressions", + array_of_list(expression, value.expressions) ] ]); }; - var literal = function (param) { - var lit = param[1]; - var raw = lit.raw; - var value = lit.value; - var loc = param[0]; - var value_; - if (typeof value !== "object") { - value_ = $$null; - } else { - switch (value.TAG) { - case "String" : - value_ = string(value._0); - break; - case "Boolean" : - value_ = bool(value._0); - break; - case "Number" : - value_ = number$1(value._0); - break; - case "RegExp" : - var match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - var props; - var exit = 0; - if (typeof value !== "object" || value.TAG !== "RegExp") { - exit = 1; - } else { - var match$1 = value._0; - var regex = obj([ - [ - "pattern", - string(match$1.pattern) - ], - [ - "flags", - string(match$1.flags) - ] - ]); - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ], - [ - "regex", - regex - ] - ]; - } - if (exit === 1) { - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ] - ]; - } - return node("Literal", loc, props); - }; - var declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) + var block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) ]]); }; - var declare_class = function (param) { - var d = param[1]; - return node("DeclareClass", param[0], [ + var function_expression = function (param) { + var _function = param[1]; + var b = _function.body; + var body; + body = b.TAG === "BodyBlock" ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ [ "id", - identifier(d.id) + option(identifier, _function.id) ], [ - "typeParameters", - option(type_parameter_declaration, d.typeParameters) + "params", + array_of_list(pattern, _function.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), _function.defaults) + ], + [ + "rest", + option(identifier, _function.rest) ], [ "body", - object_type(d.body) + body ], [ - "extends", - array_of_list(interface_extends, d.extends) + "async", + bool(_function.async) + ], + [ + "generator", + bool(_function.generator) + ], + [ + "expression", + bool(_function.expression) + ], + [ + "returnType", + option(type_annotation, _function.returnType) + ], + [ + "typeParameters", + option(type_parameter_declaration, _function.typeParameters) + ] + ]); + }; + var jsx_element = function (param) { + var element = param[1]; + return node("JSXElement", param[0], [ + [ + "openingElement", + jsx_opening(element.openingElement) + ], + [ + "closingElement", + option(jsx_closing, element.closingElement) + ], + [ + "children", + array_of_list(jsx_child, element.children) + ] + ]); + }; + var comprehension_block = function (param) { + var b = param[1]; + return node("ComprehensionBlock", param[0], [ + [ + "left", + pattern(b.left) + ], + [ + "right", + expression(b.right) + ], + [ + "each", + bool(b.each) ] ]); }; @@ -16959,11 +16415,18 @@ function parse(content, options) { array_of_list(type_param, param[1].params) ]]); }; - var type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); + var variable_declarator = function (param) { + var declarator = param[1]; + return node("VariableDeclarator", param[0], [ + [ + "id", + pattern(declarator.id) + ], + [ + "init", + option(expression, declarator.init) + ] + ]); }; var export_specifier = function (param) { var specifier = param[1]; @@ -16978,194 +16441,575 @@ function parse(content, options) { ] ]); }; - var type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); - }; - var class_implements = function (param) { - var $$implements = param[1]; - return node("ClassImplements", param[0], [ + var generic_type_qualified_identifier = function (param) { + var q = param[1]; + var id = q.qualification; + var qualification; + qualification = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ [ - "id", - identifier($$implements.id) + "qualification", + qualification ], [ - "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + "id", + identifier(q.id) ] ]); }; - var class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) + var type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) ]]); }; - var jsx_opening_attribute = function (attribute) { - if (attribute.TAG === "Attribute") { - var param = attribute._0; - var attribute$1 = param[1]; - var id = attribute$1.name; - var name; - name = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute$1.value) - ] - ]); - } else { - var param$1 = attribute._0; - return node("JSXSpreadAttribute", param$1[0], [[ - "argument", - expression(param$1[1].argument) - ]]); + var statement = function (param) { + var b = param[1]; + var loc = param[0]; + if (typeof b !== "object") { + if (b === "Empty") { + return node("EmptyStatement", loc, []); + } else { + return node("DebuggerStatement", loc, []); + } } - }; - var jsx_name = function (id) { - switch (id.TAG) { - case "Identifier" : - return jsx_identifier(id._0); - case "NamespacedName" : - return jsx_namespaced_name(id._0); - case "MemberExpression" : - return jsx_member_expression(id._0); - - } - }; - var jsx_opening = function (param) { - var opening = param[1]; - return node("JSXOpeningElement", param[0], [ - [ - "name", - jsx_name(opening.name) - ], - [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) - ], - [ - "selfClosing", - bool(opening.selfClosing) - ] - ]); - }; - var jsx_child = function (param) { - var element = param[1]; - var loc = param[0]; - switch (element.TAG) { - case "Element" : - return jsx_element([ + switch (b.TAG) { + case "Block" : + return block([ loc, - element._0 + b._0 + ]); + case "Expression" : + return node("ExpressionStatement", loc, [[ + "expression", + expression(b._0.expression) + ]]); + case "If" : + var _if = b._0; + return node("IfStatement", loc, [ + [ + "test", + expression(_if.test) + ], + [ + "consequent", + statement(_if.consequent) + ], + [ + "alternate", + option(statement, _if.alternate) + ] + ]); + case "Labeled" : + var labeled = b._0; + return node("LabeledStatement", loc, [ + [ + "label", + identifier(labeled.label) + ], + [ + "body", + statement(labeled.body) + ] + ]); + case "Break" : + return node("BreakStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case "Continue" : + return node("ContinueStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case "With" : + var _with = b._0; + return node("WithStatement", loc, [ + [ + "object", + expression(_with._object) + ], + [ + "body", + statement(_with.body) + ] + ]); + case "TypeAlias" : + return type_alias([ + loc, + b._0 + ]); + case "Switch" : + var $$switch = b._0; + return node("SwitchStatement", loc, [ + [ + "discriminant", + expression($$switch.discriminant) + ], + [ + "cases", + array_of_list($$case, $$switch.cases) + ], + [ + "lexical", + bool($$switch.lexical) + ] + ]); + case "Return" : + return node("ReturnStatement", loc, [[ + "argument", + option(expression, b._0.argument) + ]]); + case "Throw" : + return node("ThrowStatement", loc, [[ + "argument", + expression(b._0.argument) + ]]); + case "Try" : + var _try = b._0; + return node("TryStatement", loc, [ + [ + "block", + block(_try.block) + ], + [ + "handler", + option($$catch, _try.handler) + ], + [ + "guardedHandlers", + array_of_list($$catch, _try.guardedHandlers) + ], + [ + "finalizer", + option(block, _try.finalizer) + ] + ]); + case "While" : + var _while = b._0; + return node("WhileStatement", loc, [ + [ + "test", + expression(_while.test) + ], + [ + "body", + statement(_while.body) + ] + ]); + case "DoWhile" : + var dowhile = b._0; + return node("DoWhileStatement", loc, [ + [ + "body", + statement(dowhile.body) + ], + [ + "test", + expression(dowhile.test) + ] + ]); + case "For" : + var _for = b._0; + var init = function (init$1) { + if (init$1.TAG === "InitDeclaration") { + return variable_declaration(init$1._0); + } else { + return expression(init$1._0); + } + }; + return node("ForStatement", loc, [ + [ + "init", + option(init, _for.init) + ], + [ + "test", + option(expression, _for.test) + ], + [ + "update", + option(expression, _for.update) + ], + [ + "body", + statement(_for.body) + ] + ]); + case "ForIn" : + var forin = b._0; + var left = forin.left; + var left$1; + left$1 = left.TAG === "LeftDeclaration" ? variable_declaration(left._0) : expression(left._0); + return node("ForInStatement", loc, [ + [ + "left", + left$1 + ], + [ + "right", + expression(forin.right) + ], + [ + "body", + statement(forin.body) + ], + [ + "each", + bool(forin.each) + ] + ]); + case "ForOf" : + var forof = b._0; + var left$2 = forof.left; + var left$3; + left$3 = left$2.TAG === "LeftDeclaration" ? variable_declaration(left$2._0) : expression(left$2._0); + return node("ForOfStatement", loc, [ + [ + "left", + left$3 + ], + [ + "right", + expression(forof.right) + ], + [ + "body", + statement(forof.body) + ] + ]); + case "Let" : + var _let = b._0; + return node("LetStatement", loc, [ + [ + "head", + array_of_list(let_assignment, _let.head) + ], + [ + "body", + statement(_let.body) + ] + ]); + case "FunctionDeclaration" : + var fn = b._0; + var id = fn.id; + var match = id !== undefined ? [ + "FunctionDeclaration", + identifier(id) + ] : [ + "FunctionExpression", + $$null + ]; + var b$1 = fn.body; + var body; + body = b$1.TAG === "BodyBlock" ? block(b$1._0) : expression(b$1._0); + return node(match[0], loc, [ + [ + "id", + match[1] + ], + [ + "params", + array_of_list(pattern, fn.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), fn.defaults) + ], + [ + "rest", + option(identifier, fn.rest) + ], + [ + "body", + body + ], + [ + "async", + bool(fn.async) + ], + [ + "generator", + bool(fn.generator) + ], + [ + "expression", + bool(fn.expression) + ], + [ + "returnType", + option(type_annotation, fn.returnType) + ], + [ + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) + ] ]); - case "ExpressionContainer" : - return jsx_expression_container([ + case "VariableDeclaration" : + return variable_declaration([ loc, - element._0 + b._0 ]); - case "Text" : + case "ClassDeclaration" : var param$1 = [ loc, - element._0 + b._0 ]; - var text = param$1[1]; - return node("JSXText", param$1[0], [ + var c = param$1[1]; + var id$1 = c.id; + var match$1 = id$1 !== undefined ? [ + "ClassDeclaration", + identifier(id$1) + ] : [ + "ClassExpression", + $$null + ]; + return node(match$1[0], param$1[0], [ [ - "value", - string(text.value) + "id", + match$1[1] ], [ - "raw", - string(text.raw) + "body", + class_body(c.body) + ], + [ + "superClass", + option(expression, c.superClass) + ], + [ + "typeParameters", + option(type_parameter_declaration, c.typeParameters) + ], + [ + "superTypeParameters", + option(type_parameter_instantiation, c.superTypeParameters) + ], + [ + "implements", + array_of_list(class_implements, c.implements) + ], + [ + "decorators", + array_of_list(expression, c.classDecorators) + ] + ]); + case "InterfaceDeclaration" : + return interface_declaration([ + loc, + b._0 + ]); + case "DeclareVariable" : + return declare_variable([ + loc, + b._0 + ]); + case "DeclareFunction" : + return declare_function([ + loc, + b._0 + ]); + case "DeclareClass" : + return declare_class([ + loc, + b._0 + ]); + case "DeclareModule" : + var m = b._0; + var lit = m.id; + var id$2; + id$2 = lit.TAG === "Identifier" ? identifier(lit._0) : literal(lit._0); + var match$2 = m.kind; + var tmp; + tmp = match$2.TAG === "CommonJS" ? string("CommonJS") : string("ES"); + return node("DeclareModule", loc, [ + [ + "id", + id$2 + ], + [ + "body", + block(m.body) + ], + [ + "kind", + tmp + ] + ]); + case "DeclareModuleExports" : + return node("DeclareModuleExports", loc, [[ + "typeAnnotation", + type_annotation(b._0) + ]]); + case "DeclareExportDeclaration" : + var $$export = b._0; + var match$3 = $$export.declaration; + var declaration; + if (match$3 !== undefined) { + switch (match$3.TAG) { + case "Variable" : + declaration = declare_variable(match$3._0); + break; + case "Function" : + declaration = declare_function(match$3._0); + break; + case "Class" : + declaration = declare_class(match$3._0); + break; + case "DefaultType" : + declaration = _type(match$3._0); + break; + case "NamedType" : + declaration = type_alias(match$3._0); + break; + case "Interface" : + declaration = interface_declaration(match$3._0); + break; + + } + } else { + declaration = $$null; + } + return node("DeclareExportDeclaration", loc, [ + [ + "default", + bool($$export.default) + ], + [ + "declaration", + declaration + ], + [ + "specifiers", + export_specifiers($$export.specifiers) + ], + [ + "source", + option(literal, $$export.source) + ] + ]); + case "ExportDeclaration" : + var $$export$1 = b._0; + var match$4 = $$export$1.declaration; + var declaration$1 = match$4 !== undefined ? ( + match$4.TAG === "Declaration" ? statement(match$4._0) : expression(match$4._0) + ) : $$null; + return node("ExportDeclaration", loc, [ + [ + "default", + bool($$export$1.default) + ], + [ + "declaration", + declaration$1 + ], + [ + "specifiers", + export_specifiers($$export$1.specifiers) + ], + [ + "source", + option(literal, $$export$1.source) + ], + [ + "exportKind", + string(export_kind($$export$1.exportKind)) + ] + ]); + case "ImportDeclaration" : + var $$import = b._0; + var specifiers = List.map((function (id) { + switch (id.TAG) { + case "ImportNamedSpecifier" : + var match = id._0; + var local_id = match.local; + var remote_id = match.remote; + var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; + return node("ImportSpecifier", span_loc, [ + [ + "id", + identifier(remote_id) + ], + [ + "name", + option(identifier, local_id) + ] + ]); + case "ImportDefaultSpecifier" : + var id$1 = id._0; + return node("ImportDefaultSpecifier", id$1[0], [[ + "id", + identifier(id$1) + ]]); + case "ImportNamespaceSpecifier" : + var param = id._0; + return node("ImportNamespaceSpecifier", param[0], [[ + "id", + identifier(param[1]) + ]]); + + } + }), $$import.specifiers); + var match$5 = $$import.importKind; + var import_kind; + switch (match$5) { + case "ImportType" : + import_kind = "type"; + break; + case "ImportTypeof" : + import_kind = "typeof"; + break; + case "ImportValue" : + import_kind = "value"; + break; + + } + return node("ImportDeclaration", loc, [ + [ + "specifiers", + array($$Array.of_list(specifiers)) + ], + [ + "source", + literal($$import.source) + ], + [ + "importKind", + string(import_kind) ] ]); } }; - var jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ - "name", - jsx_name(param[1].name) + var jsx_expression_container = function (param) { + var expr = param[1].expression; + var expression$1; + expression$1 = expr.TAG === "Expression" ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 ]]); }; - var generic_type_qualified_identifier = function (param) { - var q = param[1]; - var id = q.qualification; - var qualification; - qualification = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("QualifiedTypeIdentifier", param[0], [ - [ - "qualification", - qualification - ], - [ - "id", - identifier(q.id) - ] - ]); - }; - var object_type = function (param) { - var o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ - [ - "properties", - array_of_list(object_type_property, o.properties) - ], - [ - "indexers", - array_of_list(object_type_indexer, o.indexers) - ], - [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) - ] - ]); - }; - var interface_extends = function (param) { - var g = param[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + var class_implements = function (param) { + var $$implements = param[1]; + return node("ClassImplements", param[0], [ [ "id", - id$1 + identifier($$implements.id) ], [ "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + option(type_parameter_instantiation, $$implements.typeParameters) ] ]); }; - var template_element = function (param) { - var element = param[1]; - var value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ - [ - "value", - value - ], - [ - "tail", - bool(element.tail) - ] - ]); + var class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); }; var function_type = function (param) { var fn = param[1]; @@ -17188,177 +17032,205 @@ function parse(content, options) { ] ]); }; - var object_property = function (param) { - if (param.TAG === "Property") { - var match = param._0; - var prop = match[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG) { - case "Literal" : - match$1 = [ - literal(lit._0), - false - ]; - break; - case "Identifier" : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case "Computed" : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - var match$2 = prop.kind; - var kind; - switch (match$2) { - case "Init" : - kind = "init"; - break; - case "Get" : - kind = "get"; - break; - case "Set" : - kind = "set"; - break; - - } - return node("Property", match[0], [ - [ - "key", - match$1[0] - ], - [ - "value", - expression(prop.value) - ], - [ - "kind", - string(kind) - ], - [ - "method", - bool(prop._method) - ], - [ - "shorthand", - bool(prop.shorthand) - ], - [ - "computed", - bool(match$1[1]) - ] - ]); - } - var match$3 = param._0; - return node("SpreadProperty", match$3[0], [[ - "argument", - expression(match$3[1].argument) - ]]); - }; - var comprehension_block = function (param) { - var b = param[1]; - return node("ComprehensionBlock", param[0], [ + var object_type = function (param) { + var o = param[1]; + return node("ObjectTypeAnnotation", param[0], [ [ - "left", - pattern(b.left) + "properties", + array_of_list(object_type_property, o.properties) ], [ - "right", - expression(b.right) + "indexers", + array_of_list(object_type_indexer, o.indexers) ], [ - "each", - bool(b.each) + "callProperties", + array_of_list(object_type_call_property, o.callProperties) ] ]); }; - var expression_or_spread = function (expr) { - if (expr.TAG === "Expression") { - return expression(expr._0); - } - var match = expr._0; - return node("SpreadElement", match[0], [[ - "argument", - expression(match[1].argument) + var jsx_identifier = function (param) { + return node("JSXIdentifier", param[0], [[ + "name", + string(param[1].name) ]]); }; - var function_expression = function (param) { - var _function = param[1]; - var b = _function.body; - var body; - body = b.TAG === "BodyBlock" ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ + var object_type_call_property = function (param) { + var callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ [ - "id", - option(identifier, _function.id) + "value", + function_type(callProperty.value) ], [ - "params", - array_of_list(pattern, _function.params) + "static", + bool(callProperty.static) + ] + ]); + }; + var object_type_property = function (param) { + var prop = param[1]; + var lit = prop.key; + var key; + switch (lit.TAG) { + case "Literal" : + key = literal(lit._0); + break; + case "Identifier" : + key = identifier(lit._0); + break; + case "Computed" : + throw { + RE_EXN_ID: "Failure", + _1: "There should not be computed object type property keys", + Error: new Error() + }; + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key ], [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) + "value", + _type(prop.value) ], [ - "rest", - option(identifier, _function.rest) + "optional", + bool(prop.optional) + ], + [ + "static", + bool(prop.static) + ] + ]); + }; + var object_type_indexer = function (param) { + var indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ + [ + "id", + identifier(indexer.id) ], [ - "body", - body + "key", + _type(indexer.key) ], [ - "async", - bool(_function.async) + "value", + _type(indexer.value) ], [ - "generator", - bool(_function.generator) - ], + "static", + bool(indexer.static) + ] + ]); + }; + var jsx_opening = function (param) { + var opening = param[1]; + return node("JSXOpeningElement", param[0], [ [ - "expression", - bool(_function.expression) + "name", + jsx_name(opening.name) ], [ - "returnType", - option(type_annotation, _function.returnType) + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) ], [ - "typeParameters", - option(type_parameter_declaration, _function.typeParameters) + "selfClosing", + bool(opening.selfClosing) ] ]); }; - var template_literal = function (param) { - var value = param[1]; - return node("TemplateLiteral", param[0], [ + var jsx_child = function (param) { + var element = param[1]; + var loc = param[0]; + switch (element.TAG) { + case "Element" : + return jsx_element([ + loc, + element._0 + ]); + case "ExpressionContainer" : + return jsx_expression_container([ + loc, + element._0 + ]); + case "Text" : + var param$1 = [ + loc, + element._0 + ]; + var text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) + ], + [ + "raw", + string(text.raw) + ] + ]); + + } + }; + var jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) + ]]); + }; + var comment = function (param) { + var c = param[1]; + var match; + match = c.TAG === "Block" ? [ + "Block", + c._0 + ] : [ + "Line", + c._0 + ]; + return node(match[0], param[0], [[ + "value", + string(match[1]) + ]]); + }; + var jsx_namespaced_name = function (param) { + var namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ [ - "quasis", - array_of_list(template_element, value.quasis) + "namespace", + jsx_identifier(namespaced_name.namespace) ], [ - "expressions", - array_of_list(expression, value.expressions) + "name", + jsx_identifier(namespaced_name.name) ] ]); }; + var jsx_attribute_value = function (param) { + if (param.TAG === "Literal") { + return literal([ + param._0, + param._1 + ]); + } else { + return jsx_expression_container([ + param._0, + param._1 + ]); + } + }; var type_param = function (param) { var tp = param[1]; var variance = function (param) { - if (param) { - return string("minus"); - } else { + if (param === "Plus") { return string("plus"); + } else { + return string("minus"); } }; return node("TypeParameter", param[0], [ @@ -17380,6 +17252,23 @@ function parse(content, options) { ] ]); }; + var function_type_param = function (param) { + var param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ + [ + "name", + identifier(param$1.name) + ], + [ + "typeAnnotation", + _type(param$1.typeAnnotation) + ], + [ + "optional", + bool(param$1.optional) + ] + ]); + }; var class_element = function (m) { if (m.TAG === "Method") { var param = m._0; @@ -17449,128 +17338,9 @@ function parse(content, options) { array_of_list(expression, method_.decorators) ] ]); - } else { - var param$1 = m._0; - var prop = param$1[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG) { - case "Literal" : - match$1 = [ - literal(lit._0), - false - ]; - break; - case "Identifier" : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case "Computed" : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - return node("ClassProperty", param$1[0], [ - [ - "key", - match$1[0] - ], - [ - "value", - option(expression, prop.value) - ], - [ - "typeAnnotation", - option(type_annotation, prop.typeAnnotation) - ], - [ - "computed", - bool(match$1[1]) - ], - [ - "static", - bool(prop.static) - ] - ]); - } - }; - var comment = function (param) { - var c = param[1]; - var match; - match = c.TAG === "Block" ? [ - "Block", - c._0 - ] : [ - "Line", - c._0 - ]; - return node(match[0], param[0], [[ - "value", - string(match[1]) - ]]); - }; - var function_type_param = function (param) { - var param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); - }; - var variable_declarator = function (param) { - var declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) - ], - [ - "init", - option(expression, declarator.init) - ] - ]); - }; - var jsx_attribute_value = function (param) { - if (param.TAG === "Literal") { - return literal([ - param._0, - param._1 - ]); - } else { - return jsx_expression_container([ - param._0, - param._1 - ]); - } - }; - var array_pattern_element = function (p) { - if (p.TAG === "Element") { - return pattern(p._0); - } - var match = p._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); - }; - var object_pattern_property = function (param) { - if (param.TAG === "Property") { - var match = param._0; - var prop = match[1]; + } else { + var param$1 = m._0; + var prop = param$1[1]; var lit = prop.key; var match$1; switch (lit.TAG) { @@ -17594,31 +17364,270 @@ function parse(content, options) { break; } - return node("PropertyPattern", match[0], [ + return node("ClassProperty", param$1[0], [ [ "key", match$1[0] ], [ - "pattern", - pattern(prop.pattern) + "value", + option(expression, prop.value) + ], + [ + "typeAnnotation", + option(type_annotation, prop.typeAnnotation) ], [ "computed", bool(match$1[1]) ], [ - "shorthand", - bool(prop.shorthand) + "static", + bool(prop.static) ] ]); } - var match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ - "argument", - pattern(match$2[1].argument) + }; + var template_element = function (param) { + var element = param[1]; + var value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ + [ + "value", + value + ], + [ + "tail", + bool(element.tail) + ] + ]); + }; + var jsx_name = function (id) { + switch (id.TAG) { + case "Identifier" : + return jsx_identifier(id._0); + case "NamespacedName" : + return jsx_namespaced_name(id._0); + case "MemberExpression" : + return jsx_member_expression(id._0); + + } + }; + var jsx_opening_attribute = function (attribute) { + if (attribute.TAG === "Attribute") { + var param = attribute._0; + var attribute$1 = param[1]; + var id = attribute$1.name; + var name; + name = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute$1.value) + ] + ]); + } else { + var param$1 = attribute._0; + return node("JSXSpreadAttribute", param$1[0], [[ + "argument", + expression(param$1[1].argument) + ]]); + } + }; + var jsx_member_expression = function (param) { + var member_expression = param[1]; + var id = member_expression._object; + var _object; + _object = id.TAG === "Identifier" ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ + [ + "object", + _object + ], + [ + "property", + jsx_identifier(member_expression.property) + ] + ]); + }; + var $$case = function (param) { + var c = param[1]; + return node("SwitchCase", param[0], [ + [ + "test", + option(expression, c.test) + ], + [ + "consequent", + array_of_list(statement, c.consequent) + ] + ]); + }; + var $$catch = function (param) { + var c = param[1]; + return node("CatchClause", param[0], [ + [ + "param", + pattern(c.param) + ], + [ + "guard", + option(expression, c.guard) + ], + [ + "body", + block(c.body) + ] + ]); + }; + var export_kind = function (param) { + if (param === "ExportType") { + return "type"; + } else { + return "value"; + } + }; + var declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + var interface_declaration = function (param) { + var i = param[1]; + return node("InterfaceDeclaration", param[0], [ + [ + "id", + identifier(i.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, i.typeParameters) + ], + [ + "body", + object_type(i.body) + ], + [ + "extends", + array_of_list(interface_extends, i.extends) + ] + ]); + }; + var type_alias = function (param) { + var alias = param[1]; + return node("TypeAlias", param[0], [ + [ + "id", + identifier(alias.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, alias.typeParameters) + ], + [ + "right", + _type(alias.right) + ] + ]); + }; + var declare_class = function (param) { + var d = param[1]; + return node("DeclareClass", param[0], [ + [ + "id", + identifier(d.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, d.typeParameters) + ], + [ + "body", + object_type(d.body) + ], + [ + "extends", + array_of_list(interface_extends, d.extends) + ] + ]); + }; + var export_specifiers = function (param) { + if (param !== undefined) { + if (param.TAG === "ExportSpecifiers") { + return array_of_list(export_specifier, param._0); + } else { + return array([node("ExportBatchSpecifier", param._0, [[ + "name", + option(identifier, param._1) + ]])]); + } + } else { + return array([]); + } + }; + var variable_declaration = function (param) { + var $$var = param[1]; + var match = $$var.kind; + var kind; + switch (match) { + case "Var" : + kind = "var"; + break; + case "Let" : + kind = "let"; + break; + case "Const" : + kind = "const"; + break; + + } + return node("VariableDeclaration", param[0], [ + [ + "declarations", + array_of_list(variable_declarator, $$var.declarations) + ], + [ + "kind", + string(kind) + ] + ]); + }; + var declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) ]]); }; + var interface_extends = function (param) { + var g = param[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === "Unqualified" ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ + [ + "id", + id$1 + ], + [ + "typeParameters", + option(type_parameter_instantiation, g.typeParameters) + ] + ]); + }; var program$2 = function (param) { return node("Program", param[0], [ [ diff --git a/jscomp/test/gpr_4519_test.js b/jscomp/test/gpr_4519_test.js index c635baf30c..a1cc069080 100644 --- a/jscomp/test/gpr_4519_test.js +++ b/jscomp/test/gpr_4519_test.js @@ -16,17 +16,17 @@ function eq(loc, x, y) { function nextFor(x) { if (x !== undefined) { - if (x) { - return ; - } else { + if (x === "Required") { return "Optional"; + } else { + return ; } } else { return "Required"; } } -eq("File \"gpr_4519_test.ml\", line 17, characters 6-13", "Optional", "Optional"); +eq("File \"gpr_4519_test.ml\", line 17, characters 6-13", nextFor("Required"), "Optional"); Mt.from_pair_suites("Gpr_4519_test", suites.contents); diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 6e2fb6a68c..2b90b28a8b 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -17,13 +17,13 @@ function eq(loc, x, y) { } var v = { - TAG: /* A0 */0, + TAG: "A0", lbl: 3, more: /* [] */0 }; var v1 = { - TAG: /* A1 */1, + TAG: "A1", more: { hd: 1, tl: { @@ -88,14 +88,14 @@ function ff(x) { } var v4 = { - TAG: /* A0 */0, + TAG: "A0", x: 0, y: 0, z: 0 }; var v5 = { - TAG: /* A1 */1, + TAG: "A1", z: 0 }; diff --git a/jscomp/test/large_record_duplication_test.js b/jscomp/test/large_record_duplication_test.js index 66e5cbe7e3..d996bb4520 100644 --- a/jscomp/test/large_record_duplication_test.js +++ b/jscomp/test/large_record_duplication_test.js @@ -103,7 +103,7 @@ function f1(x) { eq("File \"large_record_duplication_test.ml\", line 140, characters 6-13", get_x0(f1(v1)), 1); var v2 = { - TAG: /* A0 */0, + TAG: "A0", x0: 9, x1: 9, x2: 9, diff --git a/jscomp/test/lexer_test.js b/jscomp/test/lexer_test.js deleted file mode 100644 index 8f7f5a6784..0000000000 --- a/jscomp/test/lexer_test.js +++ /dev/null @@ -1,219 +0,0 @@ -'use strict'; - -var Mt = require("./mt.js"); -var List = require("../../lib/js/list.js"); -var Curry = require("../../lib/js/curry.js"); -var Lexing = require("../../lib/js/lexing.js"); -var Arith_lexer = require("./arith_lexer.js"); -var Arith_parser = require("./arith_parser.js"); -var Arith_syntax = require("./arith_syntax.js"); -var Number_lexer = require("./number_lexer.js"); - -function get_tokens(lex, str) { - var buf = Lexing.from_string(str); - var _acc = /* [] */0; - while(true) { - var acc = _acc; - var v = Curry._1(lex, buf); - if (v === "EOF") { - return List.rev(acc); - } - _acc = { - hd: v, - tl: acc - }; - continue ; - }; -} - -function f(param) { - return get_tokens(Arith_lexer.lexeme, param); -} - -function from_tokens(lst) { - var l = { - contents: lst - }; - return function (param) { - var match = l.contents; - if (match) { - l.contents = match.tl; - return match.hd; - } - throw { - RE_EXN_ID: "End_of_file", - Error: new Error() - }; - }; -} - -var lexer_suites_0 = [ - "arith_token", - (function (param) { - return { - TAG: "Eq", - _0: get_tokens(Arith_lexer.lexeme, "x + 3 + 4 + y"), - _1: { - hd: { - TAG: "IDENT", - _0: "x" - }, - tl: { - hd: "PLUS", - tl: { - hd: { - TAG: "NUMERAL", - _0: 3 - }, - tl: { - hd: "PLUS", - tl: { - hd: { - TAG: "NUMERAL", - _0: 4 - }, - tl: { - hd: "PLUS", - tl: { - hd: { - TAG: "IDENT", - _0: "y" - }, - tl: /* [] */0 - } - } - } - } - } - } - } - }; - }) -]; - -var lexer_suites_1 = { - hd: [ - "simple token", - (function (param) { - return { - TAG: "Eq", - _0: Arith_lexer.lexeme(Lexing.from_string("10")), - _1: { - TAG: "NUMERAL", - _0: 10 - } - }; - }) - ], - tl: { - hd: [ - "number_lexer", - (function (param) { - var v = { - contents: /* [] */0 - }; - var add = function (t) { - v.contents = { - hd: t, - tl: v.contents - }; - }; - Number_lexer.token(add, Lexing.from_string("32 + 32 ( ) * / ")); - return { - TAG: "Eq", - _0: List.rev(v.contents), - _1: { - hd: "number", - tl: { - hd: "32", - tl: { - hd: "new line", - tl: { - hd: "+", - tl: { - hd: "new line", - tl: { - hd: "number", - tl: { - hd: "32", - tl: { - hd: "new line", - tl: { - hd: "(", - tl: { - hd: "new line", - tl: { - hd: ")", - tl: { - hd: "new line", - tl: { - hd: "*", - tl: { - hd: "new line", - tl: { - hd: "/", - tl: { - hd: "new line", - tl: { - hd: "eof", - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - }; - }) - ], - tl: { - hd: [ - "simple number", - (function (param) { - return { - TAG: "Eq", - _0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("10"))), - _1: "10." - }; - }) - ], - tl: { - hd: [ - "arith", - (function (param) { - return { - TAG: "Eq", - _0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("x + 3 + 4 + y"))), - _1: "x+3.+4.+y" - }; - }) - ], - tl: /* [] */0 - } - } - } -}; - -var lexer_suites = { - hd: lexer_suites_0, - tl: lexer_suites_1 -}; - -Mt.from_pair_suites("Lexer_test", lexer_suites); - -exports.get_tokens = get_tokens; -exports.f = f; -exports.from_tokens = from_tokens; -exports.lexer_suites = lexer_suites; -/* Not a pure module */ diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 6fb0522e76..55e0fa3e32 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -58,9 +58,9 @@ function make_enemy(param) { 128 ]); case "GKoopa" : - if (dir) { + if (dir === "Left") { return setup_sprite(undefined, [ - 1, + 4, 10 ], [ 11, @@ -69,12 +69,12 @@ function make_enemy(param) { 16, 27 ], [ - 32, + 0, 69 ]); } else { return setup_sprite(undefined, [ - 4, + 1, 10 ], [ 11, @@ -83,14 +83,14 @@ function make_enemy(param) { 16, 27 ], [ - 0, + 32, 69 ]); } case "RKoopa" : - if (dir) { + if (dir === "Left") { return setup_sprite(undefined, [ - 1, + 4, 10 ], [ 11, @@ -99,12 +99,12 @@ function make_enemy(param) { 16, 27 ], [ - 32, + 0, 5 ]); } else { return setup_sprite(undefined, [ - 4, + 1, 10 ], [ 11, @@ -113,7 +113,7 @@ function make_enemy(param) { 16, 27 ], [ - 0, + 32, 5 ]); } @@ -251,65 +251,65 @@ function make_type(typ, dir) { typ._1, dir ]; - if (pt) { + if (pt === "BigM") { var typ$1 = spr_type[0]; - if (spr_type[1]) { + if (spr_type[1] === "Left") { switch (typ$1) { case "Standing" : return setup_sprite(undefined, [ - 1, + 2, 1 ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ + 13, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 32 + 16, + 5 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ + 12, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 16, - 48 + 48, + 6 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ + 13, + 25 + ], "mario-big.png", 4, 10, [ 16, - 16 + 27 ], [ - 16, - 32 + 0, + 37 ]); case "Crouching" : return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, + 2, 10 - ], "mario-small.png", 1, 0, [ + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 64 + 32, + 5 ]); } @@ -317,122 +317,122 @@ function make_type(typ, dir) { switch (typ$1) { case "Standing" : return setup_sprite(undefined, [ - 3, + 1, 1 ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ + 13, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 0, - 0 + 16, + 69 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ + 12, + 25 + ], "mario-big.png", 1, 0, [ 16, - 16 + 26 ], [ - 16, - 16 + 48, + 70 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ + 13, + 25 + ], "mario-big.png", 4, 10, [ 16, - 16 + 27 ], [ - 16, - 0 + 0, + 101 ]); case "Crouching" : return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, + 2, 10 - ], "mario-small.png", 1, 0, [ + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ 16, - 16 + 27 ], [ - 0, - 64 + 32, + 69 ]); } } } else { var typ$2 = spr_type[0]; - if (spr_type[1]) { + if (spr_type[1] === "Left") { switch (typ$2) { case "Standing" : return setup_sprite(undefined, [ - 1, + 3, 1 ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ + 11, + 15 + ], "mario-small.png", 1, 0, [ 16, - 26 + 16 ], [ - 16, - 69 + 0, + 0 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ + 13, + 15 + ], "mario-small.png", 2, 10, [ 16, - 26 + 16 ], [ - 48, - 70 + 16, + 16 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ + 12, + 15 + ], "mario-small.png", 3, 5, [ 16, - 27 + 16 ], [ - 0, - 101 + 16, + 0 ]); case "Crouching" : return setup_sprite(undefined, [ - 2, - 10 + 1, + 5 ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ + 14, + 10 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 32, - 69 + 0, + 64 ]); } @@ -440,59 +440,59 @@ function make_type(typ, dir) { switch (typ$2) { case "Standing" : return setup_sprite(undefined, [ - 2, + 1, 1 ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ + 11, + 15 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 16, - 5 + 0, + 32 ]); case "Jumping" : return setup_sprite(undefined, [ 2, 1 ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ + 13, + 15 + ], "mario-small.png", 2, 10, [ 16, - 26 + 16 ], [ - 48, - 6 + 16, + 48 ]); case "Running" : return setup_sprite(undefined, [ 2, 1 ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ + 12, + 15 + ], "mario-small.png", 3, 5, [ 16, - 27 + 16 ], [ - 0, - 37 + 16, + 32 ]); case "Crouching" : return setup_sprite(undefined, [ - 2, - 10 + 1, + 5 ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ + 14, + 10 + ], "mario-small.png", 1, 0, [ 16, - 27 + 16 ], [ - 32, - 5 + 0, + 64 ]); } @@ -803,10 +803,10 @@ function setup_obj(has_gravityOpt, speedOpt, param) { function set_vel_to_speed(obj) { var speed = obj.params.speed; var match = obj.dir; - if (match) { - obj.vel.x = speed; - } else { + if (match === "Left") { obj.vel.x = - speed; + } else { + obj.vel.x = speed; } } diff --git a/jscomp/test/method_chain.js b/jscomp/test/method_chain.js deleted file mode 100644 index eba6dfaa50..0000000000 --- a/jscomp/test/method_chain.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - - -function f(obj, x, y) { - return obj.paint(x, y).draw(x, y).bark(x, y); -} - -exports.f = f; -/* No side effect */ diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index beeba17e47..7ad266501b 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -3411,39 +3411,21 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - var piece = function (param) { - var r = atom(undefined); - if (accept(/* '*' */42)) { - return greedy_mod(repn(r, 0, undefined)); - } - if (accept(/* '+' */43)) { - return greedy_mod(repn(r, 1, undefined)); - } - if (accept(/* '?' */63)) { - return greedy_mod(repn(r, 0, 1)); - } - if (!accept(/* '{' */123)) { - return r; - } - var i$1 = integer(undefined); - if (i$1 !== undefined) { - var j = accept(/* ',' */44) ? integer(undefined) : i$1; - if (!accept(/* '}' */125)) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - if (j !== undefined && j < i$1) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; + var regexp$p = function (_left) { + while(true) { + var left = _left; + if (!accept(/* '|' */124)) { + return left; } - return greedy_mod(repn(r, i$1, j)); - } - i.contents = i.contents - 1 | 0; - return r; + _left = alt$1({ + hd: left, + tl: { + hd: branch$p(/* [] */0), + tl: /* [] */0 + } + }); + continue ; + }; }; var branch$p = function (_left) { while(true) { @@ -3458,135 +3440,173 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; - var atom = function (param) { - if (accept(/* '.' */46)) { - if (dotall) { - return any; - } else { - return notnl; - } + var $$char = function (param) { + if (i.contents === l) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } - if (accept(/* '(' */40)) { - if (accept(/* '?' */63)) { - if (accept(/* ':' */58)) { - var r = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { + var c = get(undefined); + if (c === /* '[' */91) { + if (accept(/* '=' */61)) { + throw { + RE_EXN_ID: Not_supported, + Error: new Error() + }; + } + if (accept(/* ':' */58)) { + var compl$1 = accept(/* '^' */94); + var cls; + try { + cls = List.find(accept_s, { + hd: "alnum", + tl: { + hd: "ascii", + tl: { + hd: "blank", + tl: { + hd: "cntrl", + tl: { + hd: "digit", + tl: { + hd: "lower", + tl: { + hd: "print", + tl: { + hd: "space", + tl: { + hd: "upper", + tl: { + hd: "word", + tl: { + hd: "punct", + tl: { + hd: "graph", + tl: { + hd: "xdigit", + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + }); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - return r; + throw exn; } - if (accept(/* '#' */35)) { - var _param; - while(true) { - if (accept(/* ')' */41)) { - return epsilon; - } - i.contents = i.contents + 1 | 0; - _param = undefined; - continue ; - }; + if (!accept_s(":]")) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } + var posix_class = posix_class_of_string(cls); + var re = compl$1 ? compl({ + hd: posix_class, + tl: /* [] */0 + }) : posix_class; + return { + NAME: "Set", + VAL: re + }; + } + if (!accept(/* '.' */46)) { + return { + NAME: "Char", + VAL: c + }; + } + if (i.contents === l) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - var r$1 = regexp$p(branch$p(/* [] */0)); - if (!accept(/* ')' */41)) { + var c$1 = get(undefined); + if (!accept(/* '.' */46)) { + throw { + RE_EXN_ID: Not_supported, + Error: new Error() + }; + } + if (!accept(/* ']' */93)) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } return { - TAG: "Group", - _0: r$1 + NAME: "Char", + VAL: c$1 }; } - if (accept(/* '^' */94)) { - if (multiline) { - return "Beg_of_line"; - } else { - return "Beg_of_str"; - } - } - if (accept(/* '$' */36)) { - if (multiline) { - return "End_of_line"; - } else if (dollar_endonly) { - return "Last_end_of_line"; - } else { - return "End_of_str"; - } - } - if (accept(/* '[' */91)) { - if (accept(/* '^' */94)) { - return compl(bracket(/* [] */0)); - } else { - return alt$1(bracket(/* [] */0)); - } - } - if (accept(/* '\\' */92)) { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() + if (c !== /* '\\' */92) { + return { + NAME: "Char", + VAL: c }; + } + var c$2 = get(undefined); + if (c$2 >= 58) { + if (c$2 >= 123) { + return { + NAME: "Char", + VAL: c$2 + }; } - var c = get(undefined); - switch (c) { - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - throw { - RE_EXN_ID: Not_supported, - Error: new Error() - }; - case 65 : - return "Beg_of_str"; - case 66 : - return "Not_bound"; + switch (c$2) { case 68 : - return compl({ - hd: digit, - tl: /* [] */0 - }); - case 71 : - return "Start"; + return { + NAME: "Set", + VAL: compl({ + hd: digit, + tl: /* [] */0 + }) + }; case 83 : - return compl({ - hd: space, - tl: /* [] */0 - }); - case 87 : - return compl({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, + return { + NAME: "Set", + VAL: compl({ + hd: space, tl: /* [] */0 - } - }); - case 90 : - return "Last_end_of_line"; + }) + }; + case 87 : + return { + NAME: "Set", + VAL: compl({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; case 58 : case 59 : case 60 : @@ -3601,41 +3621,65 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - TAG: "Set", - _0: single(c) + NAME: "Char", + VAL: c$2 }; case 98 : - return alt$1({ - hd: "Beg_of_word", - tl: { - hd: "End_of_word", - tl: /* [] */0 - } - }); + return { + NAME: "Char", + VAL: /* '\b' */8 + }; case 100 : - return digit; + return { + NAME: "Set", + VAL: digit + }; + case 110 : + return { + NAME: "Char", + VAL: /* '\n' */10 + }; + case 114 : + return { + NAME: "Char", + VAL: /* '\r' */13 + }; case 115 : - return space; + return { + NAME: "Set", + VAL: space + }; + case 116 : + return { + NAME: "Char", + VAL: /* '\t' */9 + }; case 119 : - return alt$1({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }); + return { + NAME: "Set", + VAL: alt$1({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }) + }; + case 65 : + case 66 : case 67 : case 69 : case 70 : + case 71 : case 72 : case 73 : case 74 : @@ -3652,6 +3696,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : + case 90 : case 97 : case 99 : case 101 : @@ -3663,126 +3708,33 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : - case 110 : - case 111 : - case 112 : - case 113 : - case 114 : - case 116 : - case 117 : - case 118 : - case 120 : - case 121 : - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - case 122 : - return "End_of_str"; - default: - return { - TAG: "Set", - _0: single(c) - }; - } - } else { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - var c$1 = get(undefined); - if (c$1 >= 64) { - if (c$1 !== 92) { - if (c$1 !== 123) { - return { - TAG: "Set", - _0: single(c$1) - }; - } - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - if (c$1 >= 44) { - if (c$1 >= 63) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - return { - TAG: "Set", - _0: single(c$1) - }; + case 111 : + case 112 : + case 113 : + case 117 : + case 118 : + case 120 : + case 121 : + case 122 : + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } - if (c$1 >= 42) { + } else { + if (c$2 >= 48) { throw { - RE_EXN_ID: Parse_error, + RE_EXN_ID: Not_supported, Error: new Error() }; } return { - TAG: "Set", - _0: single(c$1) + NAME: "Char", + VAL: c$2 }; } }; - var integer = function (param) { - if (i.contents === l) { - return ; - } - var d = get(undefined); - if (d > 57 || d < 48) { - i.contents = i.contents - 1 | 0; - return ; - } else { - var _i = d - /* '0' */48 | 0; - while(true) { - var i$1 = _i; - if (i.contents === l) { - return i$1; - } - var d$1 = get(undefined); - if (d$1 > 57 || d$1 < 48) { - i.contents = i.contents - 1 | 0; - return i$1; - } - var i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; - if (i$p < i$1) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - _i = i$p; - continue ; - }; - } - }; - var regexp$p = function (_left) { - while(true) { - var left = _left; - if (!accept(/* '|' */124)) { - return left; - } - _left = alt$1({ - hd: left, - tl: { - hd: branch$p(/* [] */0), - tl: /* [] */0 - } - }); - continue ; - }; - }; var bracket = function (_s) { while(true) { var s = _s; @@ -3864,173 +3816,201 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; }; - var $$char = function (param) { - if (i.contents === l) { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; + var piece = function (param) { + var r = atom(undefined); + if (accept(/* '*' */42)) { + return greedy_mod(repn(r, 0, undefined)); } - var c = get(undefined); - if (c === /* '[' */91) { - if (accept(/* '=' */61)) { + if (accept(/* '+' */43)) { + return greedy_mod(repn(r, 1, undefined)); + } + if (accept(/* '?' */63)) { + return greedy_mod(repn(r, 0, 1)); + } + if (!accept(/* '{' */123)) { + return r; + } + var i$1 = integer(undefined); + if (i$1 !== undefined) { + var j = accept(/* ',' */44) ? integer(undefined) : i$1; + if (!accept(/* '}' */125)) { throw { - RE_EXN_ID: Not_supported, + RE_EXN_ID: Parse_error, Error: new Error() }; } - if (accept(/* ':' */58)) { - var compl$1 = accept(/* '^' */94); - var cls; - try { - cls = List.find(accept_s, { - hd: "alnum", - tl: { - hd: "ascii", - tl: { - hd: "blank", - tl: { - hd: "cntrl", - tl: { - hd: "digit", - tl: { - hd: "lower", - tl: { - hd: "print", - tl: { - hd: "space", - tl: { - hd: "upper", - tl: { - hd: "word", - tl: { - hd: "punct", - tl: { - hd: "graph", - tl: { - hd: "xdigit", - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - }); + if (j !== undefined && j < i$1) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return greedy_mod(repn(r, i$1, j)); + } + i.contents = i.contents - 1 | 0; + return r; + }; + var integer = function (param) { + if (i.contents === l) { + return ; + } + var d = get(undefined); + if (d > 57 || d < 48) { + i.contents = i.contents - 1 | 0; + return ; + } else { + var _i = d - /* '0' */48 | 0; + while(true) { + var i$1 = _i; + if (i.contents === l) { + return i$1; } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - throw { - RE_EXN_ID: Parse_error, - Error: new Error() - }; - } - throw exn; + var d$1 = get(undefined); + if (d$1 > 57 || d$1 < 48) { + i.contents = i.contents - 1 | 0; + return i$1; } - if (!accept_s(":]")) { + var i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; + if (i$p < i$1) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - var posix_class = posix_class_of_string(cls); - var re = compl$1 ? compl({ - hd: posix_class, - tl: /* [] */0 - }) : posix_class; - return { - NAME: "Set", - VAL: re - }; + _i = i$p; + continue ; + }; + } + }; + var atom = function (param) { + if (accept(/* '.' */46)) { + if (dotall) { + return any; + } else { + return notnl; } - if (!accept(/* '.' */46)) { - return { - NAME: "Char", - VAL: c - }; + } + if (accept(/* '(' */40)) { + if (accept(/* '?' */63)) { + if (accept(/* ':' */58)) { + var r = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return r; + } + if (accept(/* '#' */35)) { + var _param; + while(true) { + if (accept(/* ')' */41)) { + return epsilon; + } + i.contents = i.contents + 1 | 0; + _param = undefined; + continue ; + }; + } + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; } - if (i.contents === l) { + var r$1 = regexp$p(branch$p(/* [] */0)); + if (!accept(/* ')' */41)) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - var c$1 = get(undefined); - if (!accept(/* '.' */46)) { - throw { - RE_EXN_ID: Not_supported, - Error: new Error() - }; + return { + TAG: "Group", + _0: r$1 + }; + } + if (accept(/* '^' */94)) { + if (multiline) { + return "Beg_of_line"; + } else { + return "Beg_of_str"; + } + } + if (accept(/* '$' */36)) { + if (multiline) { + return "End_of_line"; + } else if (dollar_endonly) { + return "Last_end_of_line"; + } else { + return "End_of_str"; + } + } + if (accept(/* '[' */91)) { + if (accept(/* '^' */94)) { + return compl(bracket(/* [] */0)); + } else { + return alt$1(bracket(/* [] */0)); } - if (!accept(/* ']' */93)) { + } + if (accept(/* '\\' */92)) { + if (i.contents === l) { throw { RE_EXN_ID: Parse_error, Error: new Error() }; } - return { - NAME: "Char", - VAL: c$1 - }; - } - if (c !== /* '\\' */92) { - return { - NAME: "Char", - VAL: c - }; - } - var c$2 = get(undefined); - if (c$2 >= 58) { - if (c$2 >= 123) { - return { - NAME: "Char", - VAL: c$2 - }; - } - switch (c$2) { + var c = get(undefined); + switch (c) { + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + throw { + RE_EXN_ID: Not_supported, + Error: new Error() + }; + case 65 : + return "Beg_of_str"; + case 66 : + return "Not_bound"; case 68 : - return { - NAME: "Set", - VAL: compl({ - hd: digit, - tl: /* [] */0 - }) - }; + return compl({ + hd: digit, + tl: /* [] */0 + }); + case 71 : + return "Start"; case 83 : - return { - NAME: "Set", - VAL: compl({ - hd: space, - tl: /* [] */0 - }) - }; + return compl({ + hd: space, + tl: /* [] */0 + }); case 87 : - return { - NAME: "Set", - VAL: compl({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; + return compl({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); + case 90 : + return "Last_end_of_line"; case 58 : case 59 : case 60 : @@ -4045,65 +4025,41 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 95 : case 96 : return { - NAME: "Char", - VAL: c$2 + TAG: "Set", + _0: single(c) }; case 98 : - return { - NAME: "Char", - VAL: /* '\b' */8 - }; + return alt$1({ + hd: "Beg_of_word", + tl: { + hd: "End_of_word", + tl: /* [] */0 + } + }); case 100 : - return { - NAME: "Set", - VAL: digit - }; - case 110 : - return { - NAME: "Char", - VAL: /* '\n' */10 - }; - case 114 : - return { - NAME: "Char", - VAL: /* '\r' */13 - }; + return digit; case 115 : - return { - NAME: "Set", - VAL: space - }; - case 116 : - return { - NAME: "Char", - VAL: /* '\t' */9 - }; + return space; case 119 : - return { - NAME: "Set", - VAL: alt$1({ - hd: alnum, - tl: { - hd: { - TAG: "Set", - _0: { - hd: [ - /* '_' */95, - /* '_' */95 - ], - tl: /* [] */0 - } - }, - tl: /* [] */0 - } - }) - }; - case 65 : - case 66 : + return alt$1({ + hd: alnum, + tl: { + hd: { + TAG: "Set", + _0: { + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 + } + }, + tl: /* [] */0 + } + }); case 67 : case 69 : case 70 : - case 71 : case 72 : case 73 : case 74 : @@ -4120,7 +4076,6 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 86 : case 88 : case 89 : - case 90 : case 97 : case 99 : case 101 : @@ -4132,30 +4087,75 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 107 : case 108 : case 109 : + case 110 : case 111 : case 112 : case 113 : + case 114 : + case 116 : case 117 : case 118 : case 120 : case 121 : - case 122 : throw { RE_EXN_ID: Parse_error, Error: new Error() }; - + case 122 : + return "End_of_str"; + default: + return { + TAG: "Set", + _0: single(c) + }; } } else { - if (c$2 >= 48) { + if (i.contents === l) { throw { - RE_EXN_ID: Not_supported, + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + var c$1 = get(undefined); + if (c$1 >= 64) { + if (c$1 !== 92) { + if (c$1 !== 123) { + return { + TAG: "Set", + _0: single(c$1) + }; + } + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + if (c$1 >= 44) { + if (c$1 >= 63) { + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + } + return { + TAG: "Set", + _0: single(c$1) + }; + } + if (c$1 >= 42) { + throw { + RE_EXN_ID: Parse_error, Error: new Error() }; } return { - NAME: "Char", - VAL: c$2 + TAG: "Set", + _0: single(c$1) }; } }; diff --git a/jscomp/test/rbset.js b/jscomp/test/rbset.js index fa7fe05339..f389ffab09 100644 --- a/jscomp/test/rbset.js +++ b/jscomp/test/rbset.js @@ -2,7 +2,7 @@ function blackify(s) { - if (typeof s !== "object" || !s._0) { + if (typeof s !== "object" || s._0 === "Black") { return [ s, true @@ -57,12 +57,12 @@ function balance_left(l, x, r) { var c; var z; var d; - if (typeof l !== "object" || !l._0) { + if (typeof l !== "object" || l._0 === "Black") { exit = 1; } else { var a$1 = l._1; var exit$1 = 0; - if (typeof a$1 !== "object" || !a$1._0) { + if (typeof a$1 !== "object" || a$1._0 === "Black") { exit$1 = 3; } else { a = a$1._1; @@ -76,7 +76,7 @@ function balance_left(l, x, r) { } if (exit$1 === 3) { var match = l._3; - if (typeof match !== "object" || !match._0) { + if (typeof match !== "object" || match._0 === "Black") { exit = 1; } else { a = a$1; @@ -133,12 +133,12 @@ function balance_right(l, x, r) { var c; var z; var d; - if (typeof r !== "object" || !r._0) { + if (typeof r !== "object" || r._0 === "Black") { exit = 1; } else { var b$1 = r._1; var exit$1 = 0; - if (typeof b$1 !== "object" || !b$1._0) { + if (typeof b$1 !== "object" || b$1._0 === "Black") { exit$1 = 3; } else { a = l; @@ -152,7 +152,7 @@ function balance_right(l, x, r) { } if (exit$1 === 3) { var match = r._3; - if (typeof match !== "object" || !match._0) { + if (typeof match !== "object" || match._0 === "Black") { exit = 1; } else { a = l; @@ -212,50 +212,35 @@ function singleton(x) { function unbalanced_left(param) { if (typeof param === "object") { - if (param._0) { + if (param._0 === "Black") { var match = param._1; - if (typeof match === "object" && !match._0) { - return [ - balance_left({ - TAG: "Node", - _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 - }, param._2, param._3), - false - ]; - } - - } else { - var match$1 = param._1; - if (typeof match$1 === "object") { - if (!match$1._0) { + if (typeof match === "object") { + if (match._0 === "Black") { return [ balance_left({ TAG: "Node", _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 + _1: match._1, + _2: match._2, + _3: match._3 }, param._2, param._3), true ]; } - var match$2 = match$1._3; - if (typeof match$2 === "object" && !match$2._0) { + var match$1 = match._3; + if (typeof match$1 === "object" && match$1._0 === "Black") { return [ { TAG: "Node", _0: "Black", - _1: match$1._1, - _2: match$1._2, + _1: match._1, + _2: match._2, _3: balance_left({ TAG: "Node", _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 }, param._2, param._3) }, false @@ -264,6 +249,21 @@ function unbalanced_left(param) { } + } else { + var match$2 = param._1; + if (typeof match$2 === "object" && match$2._0 === "Black") { + return [ + balance_left({ + TAG: "Node", + _0: "Red", + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 + }, param._2, param._3), + false + ]; + } + } } throw { @@ -279,40 +279,25 @@ function unbalanced_left(param) { function unbalanced_right(param) { if (typeof param === "object") { - if (param._0) { + if (param._0 === "Black") { var match = param._3; - if (typeof match === "object" && !match._0) { - return [ - balance_right(param._1, param._2, { - TAG: "Node", - _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 - }), - false - ]; - } - - } else { - var match$1 = param._3; var x = param._2; var a = param._1; - if (typeof match$1 === "object") { - if (!match$1._0) { + if (typeof match === "object") { + if (match._0 === "Black") { return [ balance_right(a, x, { TAG: "Node", _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 + _1: match._1, + _2: match._2, + _3: match._3 }), true ]; } - var match$2 = match$1._1; - if (typeof match$2 === "object" && !match$2._0) { + var match$1 = match._1; + if (typeof match$1 === "object" && match$1._0 === "Black") { return [ { TAG: "Node", @@ -320,12 +305,12 @@ function unbalanced_right(param) { _1: balance_right(a, x, { TAG: "Node", _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 }), - _2: match$1._2, - _3: match$1._3 + _2: match._2, + _3: match._3 }, false ]; @@ -333,6 +318,21 @@ function unbalanced_right(param) { } + } else { + var match$2 = param._3; + if (typeof match$2 === "object" && match$2._0 === "Black") { + return [ + balance_right(param._1, param._2, { + TAG: "Node", + _0: "Red", + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 + }), + false + ]; + } + } } throw { @@ -356,7 +356,7 @@ function lbalance(x1, x2, x3) { _3: x3 }; } - if (!x1._0) { + if (x1._0 === "Black") { return { TAG: "Node", _0: "Black", @@ -367,7 +367,7 @@ function lbalance(x1, x2, x3) { } var r = x1._3; var l = x1._1; - if (typeof l === "object" && l._0) { + if (typeof l === "object" && l._0 !== "Black") { return { TAG: "Node", _0: "Red", @@ -397,7 +397,7 @@ function lbalance(x1, x2, x3) { _3: x3 }; } - if (!r._0) { + if (r._0 === "Black") { return { TAG: "Node", _0: "Black", @@ -429,13 +429,13 @@ function lbalance(x1, x2, x3) { } function rbalance(x1, x2, x3) { - if (typeof x3 === "object" && x3._0) { + if (typeof x3 === "object" && x3._0 !== "Black") { var b = x3._1; var exit = 0; if (typeof b !== "object") { exit = 2; } else { - if (b._0) { + if (b._0 !== "Black") { return { TAG: "Node", _0: "Red", @@ -460,7 +460,7 @@ function rbalance(x1, x2, x3) { } if (exit === 2) { var match = x3._3; - if (typeof match === "object" && match._0) { + if (typeof match === "object" && match._0 !== "Black") { return { TAG: "Node", _0: "Red", @@ -504,7 +504,7 @@ function ins(x, s) { _3: "Empty" }; } - if (s._0) { + if (s._0 === "Black") { var y = s._2; if (x === y) { return s; @@ -512,21 +512,9 @@ function ins(x, s) { var b = s._3; var a = s._1; if (x < y) { - return { - TAG: "Node", - _0: "Red", - _1: ins(x, a), - _2: y, - _3: b - }; + return lbalance(ins(x, a), y, b); } else { - return { - TAG: "Node", - _0: "Red", - _1: a, - _2: y, - _3: ins(x, b) - }; + return rbalance(a, y, ins(x, b)); } } var y$1 = s._2; @@ -536,15 +524,27 @@ function ins(x, s) { var b$1 = s._3; var a$1 = s._1; if (x < y$1) { - return lbalance(ins(x, a$1), y$1, b$1); + return { + TAG: "Node", + _0: "Red", + _1: ins(x, a$1), + _2: y$1, + _3: b$1 + }; } else { - return rbalance(a$1, y$1, ins(x, b$1)); + return { + TAG: "Node", + _0: "Red", + _1: a$1, + _2: y$1, + _3: ins(x, b$1) + }; } } function add(x, s) { var s$1 = ins(x, s); - if (typeof s$1 !== "object" || !s$1._0) { + if (typeof s$1 !== "object" || s$1._0 === "Black") { return s$1; } else { return { @@ -570,19 +570,9 @@ function remove_min(param) { }; } var c = param._0; - if (c) { + if (c === "Black") { var tmp = param._1; if (typeof tmp !== "object") { - return [ - param._3, - param._2, - false - ]; - } - - } else { - var tmp$1 = param._1; - if (typeof tmp$1 !== "object") { var match = param._3; var x = param._2; if (typeof match !== "object") { @@ -592,7 +582,7 @@ function remove_min(param) { true ]; } - if (match._0) { + if (match._0 !== "Black") { return [ { TAG: "Node", @@ -616,6 +606,16 @@ function remove_min(param) { }; } + } else { + var tmp$1 = param._1; + if (typeof tmp$1 !== "object") { + return [ + param._3, + param._2, + false + ]; + } + } var match$1 = remove_min(param._1); var y = match$1[1]; diff --git a/jscomp/test/record_extension_test.js b/jscomp/test/record_extension_test.js index bb4c201075..d38f8acf70 100644 --- a/jscomp/test/record_extension_test.js +++ b/jscomp/test/record_extension_test.js @@ -48,7 +48,7 @@ function f2_with(x) { return x; } else { return { - TAG: /* C */0, + TAG: "C", x: 0, y: x.y }; diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 71cbc8561e..0cac60a5f0 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -1202,7 +1202,7 @@ function process_quote(ticker_map, new_ticker, new_value) { var match$2 = match$1.lhs.value; var match$3 = match$1.rhs.value; var value = match$2 !== undefined && match$3 !== undefined ? ( - match$1.op ? match$2 - match$3 : match$2 + match$3 + match$1.op === "PLUS" ? match$2 + match$3 : match$2 - match$3 ) : undefined; ticker.value = value; }), update_sequence); diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index 10a17b9d76..fc8ae8ad9b 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -346,7 +346,7 @@ var MyNullableExtended = { }; function area(shape) { - switch (shape.TAG) { + switch (shape.kind) { case 1 : return Math.PI * Math.pow(shape.radius, 2); case "square" : @@ -357,8 +357,35 @@ function area(shape) { } } +var TaggedUnions_circle = { + kind: 1, + radius: 10 +}; + +var TaggedUnions_square = { + kind: "square", + sideLength: 10 +}; + var TaggedUnions = { - area: area + area: area, + circle: TaggedUnions_circle, + square: TaggedUnions_square +}; + +var CustomTagNotInline_a = { + "custom-tag": "A", + _0: 10 +}; + +var CustomTagNotInline_b = { + "custom-tag": "B", + _0: 20 +}; + +var CustomTagNotInline = { + a: CustomTagNotInline_a, + b: CustomTagNotInline_b }; exports.toEnum = toEnum; @@ -377,4 +404,5 @@ exports.MyNull = MyNull; exports.MyNullable = MyNullable; exports.MyNullableExtended = MyNullableExtended; exports.TaggedUnions = TaggedUnions; +exports.CustomTagNotInline = CustomTagNotInline; /* expectSeven Not a pure module */ diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index 173e6eb1e7..60c58b3321 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -204,6 +204,7 @@ module MyNullableExtended = { let expectSeven = plus(Present({x: 4., y: 3.}), Present({x: 3., y: 4.})) Js.log2("expect {x:7, y:7}:", expectSeven) } + module TaggedUnions = { /* type Circle = { @@ -237,10 +238,11 @@ module TaggedUnions = { } } */ + @tag("kind") type shape = - | @as(1) Circle({kind: string, radius: float}) - | @as("square") Square({kind: string, sideLength: float}) - | @as("rectangle") Rectangle({kind: string, width: float, height: float}) + | @as(1) Circle({radius: float}) + | @as("square") Square({sideLength: float}) + | @as("rectangle") Rectangle({width: float, height: float}) let area = (shape: shape): float => { switch shape { @@ -249,4 +251,14 @@ module TaggedUnions = { | Rectangle({width, height}) => width *. height } } + + let circle = Circle({radius: 10.}) + let square = Square({sideLength: 10.}) +} + +module CustomTagNotInline = { + @tag("custom-tag") + type t = A(int) | B(int) + let a = A(10) + let b = B(20) } From 935951eb23f83ff3ae62da4358884983169b7a3b Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 27 Mar 2023 09:00:46 +0200 Subject: [PATCH 12/13] Document places needing restriction. --- CHANGELOG.md | 1 + jscomp/core/js_dump.ml | 1 + jscomp/core/js_exp_make.ml | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fcdea36bc..7f8870b480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Make uncurried functions a subtype of curried functions, and allow application f The `make` function of components is generated as an uncurried function. Use best effort to determine the config when formatting a file. https://github.com/rescript-lang/rescript-compiler/pull/5968 https://github.com/rescript-lang/rescript-compiler/pull/6080 https://github.com/rescript-lang/rescript-compiler/pull/6086 https://github.com/rescript-lang/rescript-compiler/pull/6087 +- Customization of runtime representation of variants. This is work in progress. E.g. some restrictions on the input. See comments of the form "TODO: put restriction on the variant definitions allowed, to make sure this never happens". https://github.com/rescript-lang/rescript-compiler/pull/6095 #### :boom: Breaking Change diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index afb85db1b3..2a84bfe921 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -811,6 +811,7 @@ and expression_desc cxt ~(level : int) f x : cxt = let exp = match objs with | [(_, e)] when as_value = Some AsUnboxed -> e.expression_desc | _ when as_value = Some AsUnboxed -> assert false (* should not happen *) + (* TODO: put restriction on the variant definitions allowed, to make sure this never happens. *) | _ -> J.Object objs in expression_desc cxt ~level f exp | Caml_block diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index ce47d46c02..cdcfc82e53 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -322,6 +322,7 @@ let as_value = function | AsNull -> nil | AsUndefined -> undefined | AsUnboxed -> assert false (* Should not emit tags for unboxed *) + (* TODO: put restriction on the variant definitions allowed, to make sure this never happens. *) let array_index ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with From a02fdf738b8905881b3ff2a071046c2efceb86b7 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 27 Mar 2023 09:15:12 +0200 Subject: [PATCH 13/13] Add support for @as(true) and @as(false) --- jscomp/core/js_exp_make.ml | 12 +++++------- jscomp/core/js_stmt_make.ml | 2 +- jscomp/frontend/ast_attributes.ml | 5 +++++ jscomp/frontend/ast_payload.ml | 14 ++++++++++++++ jscomp/frontend/ast_payload.mli | 2 ++ jscomp/frontend/bs_syntaxerr.ml | 2 +- jscomp/ml/lambda.ml | 2 +- jscomp/ml/lambda.mli | 2 +- jscomp/test/variantsMatching.js | 4 ++-- jscomp/test/variantsMatching.res | 2 +- 10 files changed, 33 insertions(+), 14 deletions(-) diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index cdcfc82e53..51305a64cf 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -316,9 +316,14 @@ let small_int i : t = | 248 -> obj_int_tag_literal | i -> int (Int32.of_int i) +let true_ : t = { comment = None; expression_desc = Bool true } +let false_ : t = { comment = None; expression_desc = Bool false } +let bool v = if v then true_ else false_ + let as_value = function | Lambda.AsString s -> str s ~delim:DStarJ | AsInt i -> small_int i + | AsBool b -> bool b | AsNull -> nil | AsUndefined -> undefined | AsUnboxed -> assert false (* Should not emit tags for unboxed *) @@ -548,13 +553,6 @@ let obj ?comment properties : t = (* currently only in method call, no dependency introduced *) -(* Static_index .....................**) - -(* var (Jident.create_js "true") *) -let true_ : t = { comment = None; expression_desc = Bool true } -let false_ : t = { comment = None; expression_desc = Bool false } -let bool v = if v then true_ else false_ - (** Arith operators *) (* Static_index .....................**) diff --git a/jscomp/core/js_stmt_make.ml b/jscomp/core/js_stmt_make.ml index 8e2587323c..7af2c46912 100644 --- a/jscomp/core/js_stmt_make.ml +++ b/jscomp/core/js_stmt_make.ml @@ -138,7 +138,7 @@ let string_switch ?(comment : string option) match switch_case with | AsString s -> if s = txt then Some x.switch_body else None - | AsInt _ | AsNull | AsUnboxed | AsUndefined -> None) + | AsInt _ | AsBool _ | AsNull | AsUnboxed | AsUndefined -> None) with | Some case -> case | None -> ( match default with Some x -> x | None -> assert false) diff --git a/jscomp/frontend/ast_attributes.ml b/jscomp/frontend/ast_attributes.ml index c73f413df3..b9ffe51bff 100644 --- a/jscomp/frontend/ast_attributes.ml +++ b/jscomp/frontend/ast_attributes.ml @@ -350,6 +350,11 @@ let process_as_value (attrs : t) = | Some i -> Bs_ast_invariant.mark_used_bs_attribute attr; st := Some (AsInt i)); + (match Ast_payload.is_single_bool payload with + | None -> () + | Some b -> + Bs_ast_invariant.mark_used_bs_attribute attr; + st := Some (AsBool b)); (match Ast_payload.is_single_ident payload with | None -> () | Some Lident "null" -> diff --git a/jscomp/frontend/ast_payload.ml b/jscomp/frontend/ast_payload.ml index 227bd80bbd..afb5d333e9 100644 --- a/jscomp/frontend/ast_payload.ml +++ b/jscomp/frontend/ast_payload.ml @@ -69,6 +69,20 @@ let is_single_int (x : t) : int option = Some (int_of_string name) | _ -> None +let is_single_bool (x : t) : bool option = + match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ({ pexp_desc = Pexp_construct ({ txt = Lident ("true" | "false" as b)}, _); _ }, _); + _; + }; + ] -> + Some (b = "true") + | _ -> None + let is_single_ident (x : t) = match x with | PStr [ diff --git a/jscomp/frontend/ast_payload.mli b/jscomp/frontend/ast_payload.mli index 563d444cd6..96c3d9e1d7 100644 --- a/jscomp/frontend/ast_payload.mli +++ b/jscomp/frontend/ast_payload.mli @@ -39,6 +39,8 @@ val is_single_string_as_ast : t -> Parsetree.expression option val is_single_int : t -> int option +val is_single_bool : t -> bool option + val is_single_ident : t -> Longident.t option val raw_as_string_exp_exn : diff --git a/jscomp/frontend/bs_syntaxerr.ml b/jscomp/frontend/bs_syntaxerr.ml index 35cb332ad2..4ba70fcf3d 100644 --- a/jscomp/frontend/bs_syntaxerr.ml +++ b/jscomp/frontend/bs_syntaxerr.ml @@ -100,7 +100,7 @@ let pp_error fmt err = | Bs_this_simple_pattern -> "%@this expect its pattern variable to be simple form" | InvalidVariantAsAnnotation -> - "A variant case annotation @as(...) must be a string or integer or null" + "A variant case annotation @as(...) must be a string or integer, boolean, null, undefined" | InvalidVariantTagAnnotation -> "A variant tag annotation @tag(...) must be a string" ) diff --git a/jscomp/ml/lambda.ml b/jscomp/ml/lambda.ml index 21de5f6e6d..cacbf4af3f 100644 --- a/jscomp/ml/lambda.ml +++ b/jscomp/ml/lambda.ml @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string | AsInt of int | AsNull | AsUndefined | AsUnboxed +type as_value = AsString of string | AsInt of int | AsBool of bool | AsNull | AsUndefined | AsUnboxed type cstr_name = {name: string; as_value: as_value option} type tag_info = diff --git a/jscomp/ml/lambda.mli b/jscomp/ml/lambda.mli index 608e93d455..2945e22095 100644 --- a/jscomp/ml/lambda.mli +++ b/jscomp/ml/lambda.mli @@ -38,7 +38,7 @@ type record_repr = | Record_regular | Record_optional -type as_value = AsString of string | AsInt of int | AsNull | AsUndefined | AsUnboxed +type as_value = AsString of string | AsInt of int | AsBool of bool | AsNull | AsUndefined | AsUnboxed type cstr_name = {name:string; as_value: as_value option} type tag_info = diff --git a/jscomp/test/variantsMatching.js b/jscomp/test/variantsMatching.js index fc8ae8ad9b..a3e4ba3132 100644 --- a/jscomp/test/variantsMatching.js +++ b/jscomp/test/variantsMatching.js @@ -141,7 +141,7 @@ function foo(x) { return 1; case 12 : return 2; - case "C" : + case false : return 3; } @@ -172,7 +172,7 @@ var CustomizeTags = { foo: foo, a: "dd", b: 12, - c: "C", + c: false, d: CustomizeTags_d, e: CustomizeTags_e }; diff --git a/jscomp/test/variantsMatching.res b/jscomp/test/variantsMatching.res index 60c58b3321..4bec11859b 100644 --- a/jscomp/test/variantsMatching.res +++ b/jscomp/test/variantsMatching.res @@ -81,7 +81,7 @@ let third2 = l => } module CustomizeTags = { - type t = | @as("dd") A | @as(12) B | C | @as("qq") D(int) | @as(42) E(int) | F(string) + type t = | @as("dd") A | @as(12) B | @as(false) C | @as("qq") D(int) | @as(42) E(int) | F(string) let foo = x => switch x {