From 14331a67a06ff919e89816fd38e57c3c3400fec8 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 20 Mar 2023 14:42:19 +0100 Subject: [PATCH 01/20] 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 a3e4ba3132..73f28cb452 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 98b17b0091ff1c349cadeb2b152b57bcf54dfa04 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 21 Mar 2023 11:45:41 +0100 Subject: [PATCH 02/20] 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 73f28cb452..a3e4ba3132 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 749ea892af7bfcf263992b858d5a2b28ce7f47ac Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 22 Mar 2023 16:52:04 +0100 Subject: [PATCH 03/20] 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/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 ++++-- 48 files changed, 856 insertions(+), 428 deletions(-) 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 e320fbb06ea1761d3e69848e6bf3e51e77a6e8b2 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 23 Mar 2023 06:38:59 +0100 Subject: [PATCH 04/20] Support @as("foo") to customize the representation of tags. --- jscomp/frontend/ast_attributes.mli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jscomp/frontend/ast_attributes.mli b/jscomp/frontend/ast_attributes.mli index c495fff9a9..7ab5bdcc05 100644 --- a/jscomp/frontend/ast_attributes.mli +++ b/jscomp/frontend/ast_attributes.mli @@ -94,4 +94,4 @@ val process_send_pipe : t -> (Parsetree.core_type * t) option val process_as_value : t -> Lambda.as_value option -val process_tag_name : t -> string option \ No newline at end of file +val process_tag_name : t -> string option From e64cbedabcfa1fe09c906295a65bfa8edb19e76f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 24 Mar 2023 11:58:19 +0100 Subject: [PATCH 05/20] Add support for @tag(...) to customize the property used for the tag. --- 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/ocaml_re_test.js | 940 +-- jscomp/test/rbset.js | 198 +- jscomp/test/record_extension_test.js | 2 +- jscomp/test/ticker.js | 2 +- 13 files changed, 3678 insertions(+), 4409 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 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/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); From ceb362e78308e07ebe4d0393d6c99dde8f4576e6 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 26 Mar 2023 05:08:07 +0200 Subject: [PATCH 06/20] GenType: removed support for `@genType.as` which has become unnecessary. --- CHANGELOG.md | 1 + Makefile | 4 +- jscomp/gentype/Annotation.ml | 80 ++++++++++++------- jscomp/gentype/Converter.ml | 15 +--- jscomp/gentype/EmitJs.ml | 4 +- jscomp/gentype/EmitText.ml | 2 +- jscomp/gentype/EmitType.ml | 6 +- jscomp/gentype/ExportModule.ml | 1 - jscomp/gentype/GenTypeCommon.ml | 9 +-- jscomp/gentype/GenTypeConfig.ml | 4 +- jscomp/gentype/GenTypeMain.ml | 5 +- jscomp/gentype/GeneratedFiles.ml | 4 +- jscomp/gentype/ModuleName.ml | 4 +- jscomp/gentype/NamedArgs.ml | 16 +--- jscomp/gentype/Paths.ml | 42 +++------- jscomp/gentype/Runtime.ml | 16 ++-- jscomp/gentype/TranslateCoreType.ml | 7 +- jscomp/gentype/TranslateStructure.ml | 9 ++- jscomp/gentype/TranslateTypeDeclarations.ml | 44 +++++----- jscomp/gentype/TranslateTypeExprFromTypes.ml | 7 +- jscomp/gentype/Translation.ml | 4 +- .../src/Docstrings.bs.js | 4 +- .../src/EmitModuleIfNoConversion.bs.js | 6 +- .../src/ExportWithRename.gen.tsx | 2 +- .../src/Hooks.gen.tsx | 15 ++-- .../src/Machine.bs.js | 3 +- .../src/NestedVariants.bs.js | 60 ++++++++------ .../src/NestedVariants.gen.tsx | 15 +--- .../src/Records.bs.js | 2 +- .../src/Records.gen.tsx | 10 +-- .../typescript-react-example/src/Records.res | 2 +- .../src/Variants.gen.tsx | 36 ++------- .../typescript-react-example/src/Variants.res | 18 ++--- .../src/VariantsWithPayload.bs.js | 12 +-- .../src/VariantsWithPayload.gen.tsx | 16 ++-- .../src/VariantsWithPayload.res | 2 +- .../src/Warnings.gen.tsx | 2 +- .../src/counter.bs.js | 3 +- 38 files changed, 227 insertions(+), 265 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7657569522..ef6137b65b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ These are only breaking changes for unformatted code. - Remove deprecated module `Printexc` - `@deriving(jsConverter)` not supported anymore for variant types https://github.com/rescript-lang/rescript-compiler/pull/6088 - New representation for variants, where the tag is a string instead of a number. https://github.com/rescript-lang/rescript-compiler/pull/6088 +- GenType: removed support for `@genType.as` for records and variants which has become unnecessary. Use the language's `@as` instead to channge the runtime representation without requiring any runtime conversion during FFI. #### :bug: Bug Fix diff --git a/Makefile b/Makefile index ddb6c97c7f..d46c9c21ce 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ bench: $(DUNE_BIN_DIR)/syntax_benchmarks dce: - reanalyze.exe -- -dce-cmt _build + reanalyze.exe -dce-cmt _build/default/jscomp ninja/ninja: ./scripts/buildNinjaBinary.js @@ -42,7 +42,7 @@ test-gentype: test-all: test test-gentype reanalyze: - reanalyze.exe -set-exit-code -all-cmt _build/default/res_syntax -suppress res_syntax/testrunner + reanalyze.exe -set-exit-code -all-cmt _build/default/jscomp -suppress res_syntax/testrunner -exclude-paths jscomp/super_errors,jscomp/outcome_printer,jscomp/ounit_tests,jscomp/ml,jscomp/js_parser,jscomp/frontend,jscomp/ext,jscomp/depends,jscomp/core,jscomp/common,jscomp/cmij,jscomp/bsb_helper,jscomp/bsb lib: build node_modules/.bin/semver node scripts/ninja.js config diff --git a/jscomp/gentype/Annotation.ml b/jscomp/gentype/Annotation.ml index 6d0c89f715..632d406851 100644 --- a/jscomp/gentype/Annotation.ml +++ b/jscomp/gentype/Annotation.ml @@ -64,46 +64,68 @@ let rec getAttributePayload checkText (attributes : Typedtree.attributes) = in match attributes with | [] -> None - | ({Asttypes.txt}, payload) :: _tl when checkText txt -> ( + | ({txt; loc}, payload) :: _tl when checkText txt -> ( + let payload = + match payload with + | PStr [] -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_eval (expr, _)} :: _) -> expr |> fromExpr + | PStr ({pstr_desc = Pstr_extension _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_value _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_primitive _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_type _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_typext _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_exception _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_module _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload + | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload + | PPat _ -> Some UnrecognizedPayload + | PSig _ -> Some UnrecognizedPayload + | PTyp _ -> Some UnrecognizedPayload + in match payload with - | PStr [] -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_eval (expr, _)} :: _) -> expr |> fromExpr - | PStr ({pstr_desc = Pstr_extension _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_value _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_primitive _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_type _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_typext _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_exception _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_module _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_recmodule _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_modtype _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_open _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_class_type _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_include _} :: _) -> Some UnrecognizedPayload - | PStr ({pstr_desc = Pstr_attribute _} :: _) -> Some UnrecognizedPayload - | PPat _ -> Some UnrecognizedPayload - | PSig _ -> Some UnrecognizedPayload - | PTyp _ -> Some UnrecognizedPayload) + | None -> None + | Some payload -> Some (loc, payload)) | _hd :: tl -> getAttributePayload checkText tl let getGenTypeAsRenaming attributes = match attributes |> getAttributePayload tagIsGenTypeAs with - | Some (StringPayload s) -> Some s + | Some (_, StringPayload s) -> Some s | None -> ( match attributes |> getAttributePayload tagIsGenType with - | Some (StringPayload s) -> Some s + | Some (_, StringPayload s) -> Some s | _ -> None) | _ -> None +(* This is not supported anymore: only use to give a warning *) +let checkUnsupportedGenTypeAsRenaming attributes = + let error ~loc = + Log_.Color.setup (); + Log_.info ~loc ~name:"Warning genType" (fun ppf () -> + Format.fprintf ppf + "@\n\ + @genType.as is not supported anymore in type definitions. Use @as \ + from the language.") + in + match attributes |> getAttributePayload tagIsGenTypeAs with + | Some (loc, _) -> error ~loc + | None -> ( + match attributes |> getAttributePayload tagIsGenType with + | Some (loc, _) -> error ~loc + | None -> ()) + let getBsAsRenaming attributes = match attributes |> getAttributePayload tagIsBsAs with - | Some (StringPayload s) -> Some s + | Some (_, StringPayload s) -> Some s | _ -> None let getBsAsInt attributes = match attributes |> getAttributePayload tagIsBsAs with - | Some (IntPayload s) -> ( + | Some (_, IntPayload s) -> ( try Some (int_of_string s) with Failure _ -> None) | _ -> None @@ -111,10 +133,12 @@ let getAttributeImportRenaming attributes = let attributeImport = attributes |> getAttributePayload tagIsGenTypeImport in let genTypeAsRenaming = attributes |> getGenTypeAsRenaming in match (attributeImport, genTypeAsRenaming) with - | Some (StringPayload importString), _ -> + | Some (_, StringPayload importString), _ -> (Some importString, genTypeAsRenaming) | ( Some - (TuplePayload [StringPayload importString; StringPayload renameString]), + ( _, + TuplePayload [StringPayload importString; StringPayload renameString] + ), _ ) -> (Some importString, Some renameString) | _ -> (None, genTypeAsRenaming) @@ -122,7 +146,7 @@ let getAttributeImportRenaming attributes = let getDocString attributes = let docPayload = attributes |> getAttributePayload tagIsOcamlDoc in match docPayload with - | Some (StringPayload docString) -> "/** " ^ docString ^ " */\n" + | Some (_, StringPayload docString) -> "/** " ^ docString ^ " */\n" | _ -> "" let hasAttribute checkText (attributes : Typedtree.attributes) = @@ -133,7 +157,7 @@ let fromAttributes ~loc (attributes : Typedtree.attributes) = else if hasAttribute (fun s -> tagIsGenType s || tagIsGenTypeAs s) attributes then ( (match attributes |> getAttributePayload tagIsGenType with - | Some UnrecognizedPayload -> () + | Some (_, UnrecognizedPayload) -> () | Some _ -> Log_.Color.setup (); Log_.info ~loc ~name:"Warning genType" (fun ppf () -> diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 9a7d1c42a2..a7e72e1ba9 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -198,10 +198,10 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface in ( ObjectC (fieldsConverted - |> List.map (fun ({nameJS; nameRE; optional}, (converter, _)) -> + |> List.map (fun ({nameJS; optional}, (converter, _)) -> { lblJS = nameJS; - lblRE = nameRE; + lblRE = nameJS; c = (match optional = Mandatory with | true -> converter @@ -357,14 +357,7 @@ let rec converterIsIdentity ~config ~toJS converter = argConverter |> converterIsIdentity ~config ~toJS:(not toJS) | GroupConverter _ -> false) | IdentC -> true - | ObjectC fieldsC -> - fieldsC - |> List.for_all (fun {lblJS; lblRE; c} -> - lblJS = lblRE - && - match c with - | OptionC c1 -> c1 |> converterIsIdentity ~config ~toJS - | _ -> c |> converterIsIdentity ~config ~toJS) + | ObjectC _ -> true | OptionC c -> c |> converterIsIdentity ~config ~toJS | PromiseC c -> c |> converterIsIdentity ~config ~toJS | TupleC innerTypesC -> @@ -456,7 +449,7 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value = groupConverters |> List.mapi (fun i (s, _optional, argConverter) -> s ^ ":" - ^ (varNamesArr.(i) + ^ ((varNamesArr.(i) [@doesNotRaise]) |> apply ~config ~converter:argConverter ~indent:indent2 ~nameGen ~toJS:notToJS ~variantTables)) |> String.concat ", " diff --git a/jscomp/gentype/EmitJs.ml b/jscomp/gentype/EmitJs.ml index 85e273a6c2..5c8bc7fb11 100644 --- a/jscomp/gentype/EmitJs.ml +++ b/jscomp/gentype/EmitJs.ml @@ -513,7 +513,9 @@ let rec readCmtFilesRecursively ~config ~env ~inputCmtTranslateTypeDeclarations let exportTypeMapFromCmt = typeDeclarations |> createExportTypeMap ~config ~fromCmtReadRecursively:true - ~file:(cmtFile |> Filename.basename |> Filename.chop_extension) + ~file: + (cmtFile |> Filename.basename + |> (Filename.chop_extension [@doesNotRaise])) in let cmtToExportTypeMap = env.cmtToExportTypeMap |> StringMap.add cmtFile exportTypeMapFromCmt diff --git a/jscomp/gentype/EmitText.ml b/jscomp/gentype/EmitText.ml index 0c208daa30..cca2c8532e 100644 --- a/jscomp/gentype/EmitText.ml +++ b/jscomp/gentype/EmitText.ml @@ -49,7 +49,7 @@ let newNameGen () = Hashtbl.create 1 let quotes x = "\"" ^ x ^ "\"" let quotesIfRequired x = - match String.length x > 0 && x.[0] = '"' with + match String.length x > 0 && (x.[0] [@doesNotRaise]) = '"' with | true -> x | false -> quotes x diff --git a/jscomp/gentype/EmitType.ml b/jscomp/gentype/EmitType.ml index c24f110b2e..d8f38ff5e2 100644 --- a/jscomp/gentype/EmitType.ml +++ b/jscomp/gentype/EmitType.ml @@ -60,7 +60,6 @@ let typeReactRef ~type_ = { mutable_ = Mutable; nameJS = reactRefCurrent; - nameRE = reactRefCurrent; optional = Mandatory; type_ = Null type_; }; @@ -68,8 +67,8 @@ let typeReactRef ~type_ = let isTypeReactRef ~fields = match fields with - | [{mutable_ = Mutable; nameJS; nameRE; optional = Mandatory}] -> - nameJS == reactRefCurrent && nameJS == nameRE + | [{mutable_ = Mutable; nameJS; optional = Mandatory}] -> + nameJS == reactRefCurrent | _ -> false let isTypeFunctionComponent ~fields type_ = @@ -182,7 +181,6 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface { mutable_ = Mutable; nameJS = name; - nameRE = name; optional = Mandatory; type_ = TypeVar value; } diff --git a/jscomp/gentype/ExportModule.ml b/jscomp/gentype/ExportModule.ml index 569526314b..e41ac52703 100644 --- a/jscomp/gentype/ExportModule.ml +++ b/jscomp/gentype/ExportModule.ml @@ -56,7 +56,6 @@ and exportModuleItemToFields = { mutable_ = Mutable; nameJS = fieldName; - nameRE = fieldName; optional = Mandatory; type_ = typeForType; } diff --git a/jscomp/gentype/GenTypeCommon.ml b/jscomp/gentype/GenTypeCommon.ml index f8b85fd3c0..ffc74372a0 100644 --- a/jscomp/gentype/GenTypeCommon.ml +++ b/jscomp/gentype/GenTypeCommon.ml @@ -18,7 +18,7 @@ type case = {label: string; labelJS: labelJS} let isJSSafePropertyName name = name = "" - || (match name.[0] with + || (match name.[0] [@doesNotRaise] with | 'A' .. 'z' -> true | _ -> false) && name @@ -36,12 +36,12 @@ let labelJSToString ?(alwaysQuotes = false) case = let len = String.length s in len > 0 && (match len > 1 with - | true -> s.[0] > '0' + | true -> (s.[0] [@doesNotRaise]) > '0' | false -> true) && let res = ref true in for i = 0 to len - 1 do - match s.[i] with + match s.[i] [@doesNotRaise] with | '0' .. '9' -> () | _ -> res := false done; @@ -78,7 +78,6 @@ and argType = {aName: string; aType: type_} and field = { mutable_: mutable_; nameJS: string; - nameRE: string; optional: optional; type_: type_; } @@ -248,7 +247,7 @@ module NodeFilename = struct let concat dirname filename = let isDirSep s i = - let c = s.[i] in + let c = (s.[i] [@doesNotRaise]) in c = '/' || c = '\\' || c = ':' in let l = length dirname in diff --git a/jscomp/gentype/GenTypeConfig.ml b/jscomp/gentype/GenTypeConfig.ml index 9f8fdfda80..6e63c7a344 100644 --- a/jscomp/gentype/GenTypeConfig.ml +++ b/jscomp/gentype/GenTypeConfig.ml @@ -76,7 +76,9 @@ let getShims map = | Ext_json_types.Str {str} -> let fromTo = str |> String.split_on_char '=' |> Array.of_list in assert (Array.length fromTo == 2); - shims := (fromTo.(0), fromTo.(1)) :: !shims + shims := + ((fromTo.(0) [@doesNotRaise]), (fromTo.(1) [@doesNotRaise])) + :: !shims | _ -> ()) | _ -> ()); !shims diff --git a/jscomp/gentype/GenTypeMain.ml b/jscomp/gentype/GenTypeMain.ml index 8701ada832..7269de6451 100644 --- a/jscomp/gentype/GenTypeMain.ml +++ b/jscomp/gentype/GenTypeMain.ml @@ -126,7 +126,9 @@ let processCmtFile cmt = inputCMT |> cmtCheckAnnotations ~checkAnnotation in if isInterface then - let cmtFileImpl = (cmtFile |> Filename.chop_extension) ^ ".cmt" in + let cmtFileImpl = + (cmtFile |> (Filename.chop_extension [@doesNotRaise])) ^ ".cmt" + in let inputCMTImpl = readCmt cmtFileImpl in let hasGenTypeAnnotationsImpl = inputCMTImpl @@ -168,3 +170,4 @@ let processCmtFile cmt = else ( outputFile |> GeneratedFiles.logFileAction NoMatch; if Sys.file_exists outputFile then Sys.remove outputFile) + [@@live] diff --git a/jscomp/gentype/GeneratedFiles.ml b/jscomp/gentype/GeneratedFiles.ml index 69ff5a30aa..5b22a99b3d 100644 --- a/jscomp/gentype/GeneratedFiles.ml +++ b/jscomp/gentype/GeneratedFiles.ml @@ -27,7 +27,7 @@ let readLines (file : string) : string list = done; [] with End_of_file -> - close_in chan; + close_in chan [@doesNotRaise]; !lines |> List.rev in finished_lines @@ -37,7 +37,7 @@ let readFile (file : string) : string = String.concat "\n" (readLines file) let writeFile (filePath : string) (contents : string) = let outFile = open_out filePath in output_string outFile contents; - close_out outFile + close_out outFile [@doesNotRaise] let writeFileIfRequired ~outputFile ~fileContents = if Sys.file_exists outputFile then diff --git a/jscomp/gentype/ModuleName.ml b/jscomp/gentype/ModuleName.ml index 90a745018d..0ffb8f15be 100644 --- a/jscomp/gentype/ModuleName.ml +++ b/jscomp/gentype/ModuleName.ml @@ -13,7 +13,9 @@ let sanitizeId s = | c -> c) else s in - if s <> "" && s.[0] >= 'A' && s.[0] <= 'z' then s else "_" ^ s + if s <> "" && (s.[0] [@doesNotRaise]) >= 'A' && (s.[0] [@doesNotRaise]) <= 'z' + then s + else "_" ^ s let forBsFile s = sanitizeId s ^ "BS" diff --git a/jscomp/gentype/NamedArgs.ml b/jscomp/gentype/NamedArgs.ml index e4731a3609..18b39ab58d 100644 --- a/jscomp/gentype/NamedArgs.ml +++ b/jscomp/gentype/NamedArgs.ml @@ -14,25 +14,13 @@ let rec groupReversed ~revCurGroup ~revResult labeledTypes = (* Add it to the current group, not result. *) groupReversed ~revCurGroup: - ({ - mutable_ = Immutable; - nameJS = name; - nameRE = name; - optional = Optional; - type_; - } + ({mutable_ = Immutable; nameJS = name; optional = Optional; type_} :: revCurGroup) ~revResult tl | _, (Label name, type_) :: tl -> groupReversed ~revCurGroup: - ({ - mutable_ = Immutable; - nameJS = name; - nameRE = name; - optional = Mandatory; - type_; - } + ({mutable_ = Immutable; nameJS = name; optional = Mandatory; type_} :: revCurGroup) ~revResult tl | [], [] -> revResult diff --git a/jscomp/gentype/Paths.ml b/jscomp/gentype/Paths.ml index 67d5724f39..c1c35b0c24 100644 --- a/jscomp/gentype/Paths.ml +++ b/jscomp/gentype/Paths.ml @@ -5,25 +5,28 @@ let concat = Filename.concat let handleNamespace cmt = let cutAfterDash s = match String.index s '-' with - | n -> String.sub s 0 n + | n -> String.sub s 0 n [@doesNotRaise] | exception Not_found -> s in let noDir = Filename.basename cmt = cmt in - if noDir then cmt |> Filename.chop_extension |> cutAfterDash + if noDir then cmt |> (Filename.chop_extension [@doesNotRaise]) |> cutAfterDash else let dir = cmt |> Filename.dirname in let base = - cmt |> Filename.basename |> Filename.chop_extension |> cutAfterDash + cmt |> Filename.basename |> (Filename.chop_extension [@doesNotRaise]) + |> cutAfterDash in Filename.concat dir base let findNameSpace cmt = let keepAfterDash s = match String.index s '-' with - | n -> Some (String.sub s (n + 1) (String.length s - n - 1)) + | n -> + Some ((String.sub s (n + 1) [@doesNotRaise]) (String.length s - n - 1)) | exception Not_found -> None in - cmt |> Filename.basename |> Filename.chop_extension |> keepAfterDash + cmt |> Filename.basename |> (Filename.chop_extension [@doesNotRaise]) + |> keepAfterDash let getOutputFileRelative ~config cmt = (cmt |> handleNamespace) ^ EmitType.outputFileSuffix ~config @@ -43,9 +46,11 @@ let getCmtFile cmt = let baseName = pathCmt |> Filename.basename in Filename.concat dirName (baseName |> String.uncapitalize_ascii) in - let pathCmti = Filename.chop_extension pathCmt ^ ".cmti" in + let pathCmti = + (Filename.chop_extension pathCmt [@doesNotRaise]) ^ ".cmti" + in let pathCmtiLowerCase = - Filename.chop_extension pathCmtLowerCase ^ ".cmti" + (Filename.chop_extension pathCmtLowerCase [@doesNotRaise]) ^ ".cmti" in if Sys.file_exists pathCmtiLowerCase then pathCmtiLowerCase else if Sys.file_exists pathCmti then pathCmti @@ -62,27 +67,4 @@ let getBsConfigFile ~projectRoot = | true -> Some bsconfig | false -> None -(** Find the relative path from /.../bs/lib - e.g. /foo/bar/bs/lib/src/Hello.res --> src/Hello.res *) -let relativePathFromBsLib fileName = - if Filename.is_relative fileName then fileName - else - let rec pathToList path = - let isRoot = path |> Filename.basename = path in - match isRoot with - | true -> [path] - | false -> - (path |> Filename.basename) :: (path |> Filename.dirname |> pathToList) - in - let rec fromLibBs ~acc reversedList = - match reversedList with - | "bs" :: "lib" :: _ -> acc - | dir :: dirs -> fromLibBs ~acc:(dir :: acc) dirs - | [] -> [] - in - fileName |> pathToList |> fromLibBs ~acc:[] |> fun l -> - match l with - | [] -> fileName - | root :: dirs -> dirs |> List.fold_left concat root - let readConfig ~namespace = Config.readConfig ~getBsConfigFile ~namespace diff --git a/jscomp/gentype/Runtime.ml b/jscomp/gentype/Runtime.ml index 97a3ace75c..e74ccc2803 100644 --- a/jscomp/gentype/Runtime.ml +++ b/jscomp/gentype/Runtime.ml @@ -92,7 +92,8 @@ let emitJSVariantWithPayload ~label ~polymorphic x = ^ ":" ^ x ^ "}" let isMutableObjectField name = - String.length name >= 2 && String.sub name (String.length name - 2) 2 = "#=" + String.length name >= 2 + && (String.sub name (String.length name - 2) 2 [@doesNotRaise]) = "#=" (** Mutable fields, i.e. fields annotated "[@bs.set]" are represented as extra fields called "fieldName#=" @@ -173,12 +174,15 @@ module Mangle = struct *) let translate x = let len = x |> String.length in - if len > 2 && x.[len - 1] = '_' && x.[len - 2] = '_' then - (* "foo__" -> "foo" *) String.sub x 0 (len - 2) - else if len > 1 && x.[0] = '_' then - if x.[1] >= 'A' && x.[1] <= 'Z' then + if + len > 2 + && (x.[len - 1] [@doesNotRaise]) = '_' + && (x.[len - 2] [@doesNotRaise]) = '_' + then (* "foo__" -> "foo" *) String.sub x 0 (len - 2) [@doesNotRaise] + else if len > 1 && (x.[0] [@doesNotRaise]) = '_' then + if (x.[1] [@doesNotRaise]) >= 'A' && (x.[1] [@doesNotRaise]) <= 'Z' then (* "_Uppercase" => "Uppercase"s *) - String.sub x 1 (len - 1) + String.sub x 1 (len - 1) [@doesNotRaise] else (* "_rec" -> "rec" *) match Hashtbl.find table x with diff --git a/jscomp/gentype/TranslateCoreType.ml b/jscomp/gentype/TranslateCoreType.ml index 5053d3d0ac..6af7576b62 100644 --- a/jscomp/gentype/TranslateCoreType.ml +++ b/jscomp/gentype/TranslateCoreType.ml @@ -93,12 +93,7 @@ let rec translateArrowType ~config ~typeVarsGen ~noFunctionReturnDependencies |> translateArrowType ~config ~typeVarsGen ~noFunctionReturnDependencies ~typeEnv ~revArgDeps:nextRevDeps ~revArgs: - (( OptLabel - (match asLabel = "" with - | true -> lbl |> Runtime.mangleObjectField - | false -> asLabel), - type1 ) - :: revArgs)) + ((OptLabel (lbl |> Runtime.mangleObjectField), type1) :: revArgs)) | _ -> let {dependencies; type_ = retType} = coreType |> translateCoreType_ ~config ~typeVarsGen ~typeEnv diff --git a/jscomp/gentype/TranslateStructure.ml b/jscomp/gentype/TranslateStructure.ml index 0b0bcdd29a..b7ec562c76 100644 --- a/jscomp/gentype/TranslateStructure.ml +++ b/jscomp/gentype/TranslateStructure.ml @@ -20,7 +20,8 @@ let rec addAnnotationsToTypes_ ~config ~(expr : Typedtree.expression) match path |> TranslateTypeExprFromTypes.pathToList |> List.rev with | ["Js"; "Internal"; fn_mk] when (* Uncurried function definition uses Js.Internal.fn_mkX(...) *) - String.length fn_mk >= 5 && String.sub fn_mk 0 5 = "fn_mk" -> + String.length fn_mk >= 5 + && (String.sub fn_mk 0 5 [@doesNotRaise]) = "fn_mk" -> argTypes |> addAnnotationsToTypes_ ~config ~expr:expr1 | _ -> argTypes) | _ -> argTypes @@ -44,11 +45,11 @@ and addAnnotationsToFields ~config (expr : Typedtree.expression) let nextFields1, types1 = addAnnotationsToFields ~config c_rhs nextFields argTypes in - let nameJS, nameRE = + let name = TranslateTypeDeclarations.renameRecordField - ~attributes:expr.exp_attributes ~nameRE:field.nameRE + ~attributes:expr.exp_attributes ~name:field.nameJS in - ({field with nameJS; nameRE} :: nextFields1, types1) + ({field with nameJS = name} :: nextFields1, types1) | _ -> (fields, argTypes) (** Recover from expr the renaming annotations on named arguments. *) diff --git a/jscomp/gentype/TranslateTypeDeclarations.ml b/jscomp/gentype/TranslateTypeDeclarations.ml index a8229d876d..e5155f8c19 100644 --- a/jscomp/gentype/TranslateTypeDeclarations.ml +++ b/jscomp/gentype/TranslateTypeDeclarations.ml @@ -23,10 +23,10 @@ let createCase (label, attributes) = match attributes |> Annotation.getAttributePayload Annotation.tagIsGenTypeAs with - | Some (BoolPayload b) -> {label; labelJS = BoolLabel b} - | Some (FloatPayload s) -> {label; labelJS = FloatLabel s} - | Some (IntPayload i) -> {label; labelJS = IntLabel i} - | Some (StringPayload asLabel) -> {label; labelJS = StringLabel asLabel} + | Some (_, BoolPayload b) -> {label; labelJS = BoolLabel b} + | Some (_, FloatPayload s) -> {label; labelJS = FloatLabel s} + | Some (_, IntPayload i) -> {label; labelJS = IntLabel i} + | Some (_, StringPayload asLabel) -> {label; labelJS = StringLabel asLabel} | _ -> {label; labelJS = StringLabel label} (** @@ -35,15 +35,13 @@ let createCase (label, attributes) = * If @bs.as is used (with records-as-objects active), escape and quote if * the identifier contains characters which are invalid as JS property names. *) -let renameRecordField ~attributes ~nameRE = - match attributes |> Annotation.getGenTypeAsRenaming with - | Some nameJS -> (nameJS, nameRE) - | None -> ( - match attributes |> Annotation.getBsAsRenaming with - | Some nameBS -> - let escapedName = nameBS |> String.escaped in - (escapedName, escapedName) - | None -> (nameRE, nameRE)) +let renameRecordField ~attributes ~name = + attributes |> Annotation.checkUnsupportedGenTypeAsRenaming; + match attributes |> Annotation.getBsAsRenaming with + | Some nameBS -> + let escapedName = nameBS |> String.escaped in + escapedName + | None -> name let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver ~typeAttributes ~typeEnv ~typeName ~typeVars declarationKind : @@ -88,17 +86,16 @@ let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver let fieldTranslations = labelDeclarations |> List.map (fun {Types.ld_id; ld_mutable; ld_type; ld_attributes} -> - let nameJS, nameRE = + let name = renameRecordField ~attributes:ld_attributes - ~nameRE:(ld_id |> Ident.name) + ~name:(ld_id |> Ident.name) in let mutability = match ld_mutable = Mutable with | true -> Mutable | false -> Immutable in - ( nameJS, - nameRE, + ( name, mutability, ld_type |> TranslateTypeExprFromTypes.translateTypeExprFromTypes ~config @@ -106,21 +103,19 @@ let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver in let dependencies = fieldTranslations - |> List.map (fun (_, _, _, {TranslateTypeExprFromTypes.dependencies}) -> + |> List.map (fun (_, _, {TranslateTypeExprFromTypes.dependencies}) -> dependencies) |> List.concat in let fields = fieldTranslations - |> List.map - (fun (nameJS, nameRE, mutable_, {TranslateTypeExprFromTypes.type_}) - -> + |> List.map (fun (name, mutable_, {TranslateTypeExprFromTypes.type_}) -> let optional, type1 = match type_ with - | Option type1 when isOptional nameRE -> (Optional, type1) + | Option type1 when isOptional name -> (Optional, type1) | _ -> (Mandatory, type_) in - {mutable_; nameJS; nameRE; optional; type_ = type1}) + {mutable_; nameJS = name; optional; type_ = type1}) in let type_ = match fields with @@ -190,7 +185,8 @@ let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver variant.payloads |> List.length = (rowFieldsVariants.payloads |> List.length) then - List.combine variant.payloads rowFieldsVariants.payloads + (List.combine variant.payloads rowFieldsVariants.payloads + [@doesNotRaise]) |> List.map (fun (payload, (label, attributes, _)) -> let case = (label, attributes) |> createCase in {payload with case}) diff --git a/jscomp/gentype/TranslateTypeExprFromTypes.ml b/jscomp/gentype/TranslateTypeExprFromTypes.ml index 7d0b966474..4e0edb6bf4 100644 --- a/jscomp/gentype/TranslateTypeExprFromTypes.ml +++ b/jscomp/gentype/TranslateTypeExprFromTypes.ml @@ -45,7 +45,7 @@ let translateObjType closedFlag fieldsTranslations = | _ -> (Mandatory, t) in let name = name |> Runtime.mangleObjectField in - {mutable_; nameJS = name; nameRE = name; optional; type_}) + {mutable_; nameJS = name; optional; type_}) in let type_ = Object (closedFlag, fields) in {dependencies; type_} @@ -124,7 +124,6 @@ let translateConstr ~config ~paramsTranslation ~(path : Path.t) ~typeEnv = { mutable_ = Mutable; nameJS = "contents"; - nameRE = "contents"; optional = Mandatory; type_ = paramTranslation.type_; }; @@ -453,7 +452,7 @@ and translateTypeExprFromTypes_ ~config ~typeVarsGen ~typeEnv match typeEnv |> TypeEnv.lookupModuleTypeSignature ~path with | Some (signature, typeEnv) -> let typeEquationsTranslation = - List.combine ids types + (List.combine ids types [@doesNotRaise]) |> List.map (fun (x, t) -> ( x, t |> translateTypeExprFromTypes_ ~config ~typeVarsGen ~typeEnv @@ -503,7 +502,6 @@ and signatureToModuleRuntimeRepresentation ~config ~typeVarsGen ~typeEnv { mutable_ = Immutable; nameJS = id |> Ident.name; - nameRE = id |> Ident.name; optional = Mandatory; type_; } @@ -527,7 +525,6 @@ and signatureToModuleRuntimeRepresentation ~config ~typeVarsGen ~typeEnv { mutable_ = Immutable; nameJS = id |> Ident.name; - nameRE = id |> Ident.name; optional = Mandatory; type_; } diff --git a/jscomp/gentype/Translation.ml b/jscomp/gentype/Translation.ml index bd787eadb9..a7851ceedf 100644 --- a/jscomp/gentype/Translation.ml +++ b/jscomp/gentype/Translation.ml @@ -90,9 +90,9 @@ let translateValue ~attributes ~config ~docString ~outputFileRelative ~resolver |> addAnnotationsToFunction in let resolvedNameOriginal = - name |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString + nameAs |> TypeEnv.addModulePath ~typeEnv |> ResolvedName.toString in - let resolvedName = nameAs |> TypeEnv.addModulePath ~typeEnv in + let resolvedName = name |> TypeEnv.addModulePath ~typeEnv in let moduleAccessPath = typeEnv |> TypeEnv.getModuleAccessPath ~name:resolvedNameOriginal in diff --git a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.bs.js index 234fe8b1ef..83dc9626b8 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.bs.js @@ -66,11 +66,11 @@ function unitArgWithoutConversionU(param) { } function unitArgWithConversion(param) { - return /* A */0; + return "A"; } function unitArgWithConversionU(param) { - return /* A */0; + return "A"; } var flat = 34; diff --git a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.bs.js b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.bs.js index fcfe4dd8b6..f73e0e7ede 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.bs.js @@ -2,11 +2,11 @@ function foo(t) { - if (t) { - console.log("B" + t.name); - } else { + if (typeof t !== "object") { console.log("A"); + return ; } + console.log("B" + t.name); } var X = { diff --git a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx index 7b7416701c..127a44dd7d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ExportWithRename.gen.tsx @@ -11,4 +11,4 @@ const ExportWithRenameBS: any = ExportWithRenameBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal export type Props = { readonly s: string }; -export const ExportWithRename: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.make; +export const make: React.ComponentType<{ readonly s: string }> = ExportWithRenameBS.ExportWithRename; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx index 8ace239838..29db86f649 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx @@ -98,14 +98,7 @@ export const WithRename_componentWithRenamedArgs: React.ComponentType<{ readonly Type: vehicle; readonly to: vehicle; readonly cb: cb -}> = function Hooks_WithRename_componentWithRenamedArgs(Arg1: any) { - const $props = {Type:Arg1.Type, to:Arg1.to, cb:function (Argto: any) { - const result1 = Arg1.cb({to:Argto}); - return result1 - }}; - const result = React.createElement(HooksBS.WithRename.componentWithRenamedArgs, $props); - return result -}; +}> = HooksBS.WithRename.componentWithRenamedArgs; export const WithRef_makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element = function (Arg1: any, Arg2: any) { const result = Curry._2(HooksBS.WithRef.makeWithRef, Arg1, Arg2); @@ -172,6 +165,12 @@ export const Inner: { export const RenderPropRequiresConversion: { make: React.ComponentType<{ readonly renderVehicle: React.ComponentType<{ readonly number: number; readonly vehicle: vehicle }> }> } = HooksBS.RenderPropRequiresConversion +export const WithRename: { componentWithRenamedArgs: React.ComponentType<{ + readonly Type: vehicle; + readonly to: vehicle; + readonly cb: cb +}> } = HooksBS.WithRename + export const ForwardRef: { input: React.ComponentType<{ readonly r: r }> } = HooksBS.ForwardRef export const Fun: { functionReturningReactElement: React.ComponentType<{ readonly name: string }> } = HooksBS.Fun diff --git a/jscomp/gentype_tests/typescript-react-example/src/Machine.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Machine.bs.js index c700735f9e..6ec89819c8 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Machine.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Machine.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -var a = /* A */{ +var a = { + TAG: "A", _0: 3 }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.bs.js b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.bs.js index 6fc78a38fa..96669d6b4e 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.bs.js @@ -2,7 +2,8 @@ function makeVariant(param) { - return /* NonUnary */{ + return { + TAG: "NonUnary", _0: 5, _1: 3 }; @@ -10,10 +11,10 @@ function makeVariant(param) { function makeABC(param) { return { - TAG: /* A */0, + TAG: "A", _0: { c: { - TAG: /* C */0, + TAG: "C", _0: "a string" } }, @@ -24,7 +25,7 @@ function makeABC(param) { function makeBC(param) { return { c: { - TAG: /* C */0, + TAG: "C", _0: "a string" } }; @@ -32,9 +33,9 @@ function makeBC(param) { function makeAC(param) { return { - TAG: /* A */0, + TAG: "A", _0: { - TAG: /* C */0, + TAG: "C", _0: "a string" }, _1: 5 @@ -43,8 +44,9 @@ function makeAC(param) { function makeAD(param) { return { - TAG: /* A */0, - _0: /* Int */{ + TAG: "A", + _0: { + TAG: "Int", _0: 3 }, _1: 5 @@ -53,7 +55,7 @@ function makeAD(param) { function makeAE(param) { return { - TAG: /* A */0, + TAG: "A", _0: 3, _1: 5 }; @@ -61,8 +63,9 @@ function makeAE(param) { function makeFD(param) { return { - TAG: /* F */0, - _0: /* Int */{ + TAG: "F", + _0: { + TAG: "Int", _0: 3 } }; @@ -70,8 +73,9 @@ function makeFD(param) { function makeHD(param) { return { - TAG: /* H */0, - _0: /* Int */{ + TAG: "H", + _0: { + TAG: "Int", _0: 5 }, _1: 5 @@ -79,23 +83,29 @@ function makeHD(param) { } function makeJ(param) { - return /* J */{ - _0: /* Int */{ + return { + TAG: "J", + _0: { + TAG: "Int", _0: 5 }, - _1: /* Int */{ + _1: { + TAG: "Int", _0: 3 } }; } function makeK(param) { - return /* K */{ + return { + TAG: "K", _0: [ - /* Int */{ + { + TAG: "Int", _0: 5 }, - /* Int */{ + { + TAG: "Int", _0: 3 } ] @@ -111,18 +121,18 @@ function testUnboxedBinary(param) { } function testInline(x) { - switch (x.TAG | 0) { - case /* I */0 : + switch (x.TAG) { + case "I" : return { - TAG: /* I */0, + TAG: "I", i: x.i, j: x.j }; - case /* J */1 : + case "J" : return x; - case /* K */2 : + case "K" : return { - TAG: /* K */2, + TAG: "K", _0: x._1, _1: x._0 }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx index 7d780d6811..bc3d729a61 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx @@ -66,20 +66,11 @@ export const makeVariant: () => typeL = function () { export const makeABC: () => typeA = function () { const result = NestedVariantsBS.makeABC(); return result.TAG===0 - ? {tag:"A", value:[{c:result._0.c.TAG===0 - ? {tag:"C", value:result._0.c._0} - : {tag:"D", value:result._0.c._0}}, result._1]} - : {tag:"B", value:[{c:result._0.c.TAG===0 - ? {tag:"C", value:result._0.c._0} - : {tag:"D", value:result._0.c._0}}, result._1]} + ? {tag:"A", value:[result._0, result._1]} + : {tag:"B", value:[result._0, result._1]} }; -export const makeBC: () => typeB = function () { - const result = NestedVariantsBS.makeBC(); - return {c:result.c.TAG===0 - ? {tag:"C", value:result.c._0} - : {tag:"D", value:result.c._0}} -}; +export const makeBC: () => typeB = NestedVariantsBS.makeBC; export const makeAC: () => typeA = function () { const result = NestedVariantsBS.makeAC(); diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Records.bs.js index ad5795b116..f72740474c 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.bs.js @@ -106,7 +106,7 @@ function computeArea4(o) { } function testMyRec(x) { - return x.type_; + return x.type; } function testMyRec2(x) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx index 65e582ba1a..8f55429085 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx @@ -113,15 +113,9 @@ export const computeArea4: (o:{ readonly z?: number }) => number = RecordsBS.computeArea4; -export const testMyRec: (x:myRec) => string = function (Arg1: any) { - const result = RecordsBS.testMyRec({type_:Arg1.type}); - return result -}; +export const testMyRec: (x:myRec) => string = RecordsBS.testMyRec; -export const testMyRec2: (x:myRec) => myRec = function (Arg1: any) { - const result = RecordsBS.testMyRec2({type_:Arg1.type}); - return {type:result.type_} -}; +export const testMyRec2: (x:myRec) => myRec = RecordsBS.testMyRec2; export const testMyObj: (x:myObj) => string = RecordsBS.testMyObj; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.res b/jscomp/gentype_tests/typescript-react-example/src/Records.res index bfaceb0742..c8485e092e 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.res @@ -108,7 +108,7 @@ let computeArea4 = (o: {"x": int, "y": int, "z": option}) => @genType type myRec = { - @genType.as("type") + @as("type") type_: string, } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx index 7244a0abe3..efa3c07cd5 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx @@ -2,14 +2,6 @@ /* eslint-disable import/first */ -const $$toJS508922110: { [key: string]: any } = {"type_": "type", "module_": "module", "fortytwo": "42"}; - -const $$toRE508922110: { [key: string]: any } = {"type": "type_", "module": "module_", "42": "fortytwo"}; - -const $$toJS584768163: { [key: string]: any } = {"type_": "type", "module_": "module", "fortytwo": "XXX THIS IS DIFFERENT"}; - -const $$toRE584768163: { [key: string]: any } = {"type": "type_", "module": "module_", "XXX THIS IS DIFFERENT": "fortytwo"}; - const $$toJS930788378: { [key: string]: any } = {"x": "x", "x1": "same"}; const $$toRE930788378: { [key: string]: any } = {"x": "x", "same": "x1"}; @@ -33,13 +25,13 @@ export type weekday = | "sunday"; // tslint:disable-next-line:interface-over-type-literal -export type testGenTypeAs = "type" | "module" | "42"; +export type testGenTypeAs = "type_" | "module_" | "fortytwo"; // tslint:disable-next-line:interface-over-type-literal -export type testGenTypeAs2 = "type" | "module" | "42"; +export type testGenTypeAs2 = "type_" | "module_" | "fortytwo"; // tslint:disable-next-line:interface-over-type-literal -export type testGenTypeAs3 = "type" | "module" | "XXX THIS IS DIFFERENT"; +export type testGenTypeAs3 = "type_" | "module_" | "fortytwo"; // tslint:disable-next-line:interface-over-type-literal export type x1 = "x" | "same"; @@ -78,29 +70,17 @@ export const onlySunday: (param:"sunday") => void = VariantsBS.onlySunday; export const swap: (x:"saturday" | "sunday") => "saturday" | "sunday" = VariantsBS.swap; -export const testConvert: (x:testGenTypeAs) => testGenTypeAs = function (Arg1: any) { - const result = VariantsBS.testConvert($$toRE508922110[Arg1]); - return $$toJS508922110[result] -}; +export const testConvert: (x:testGenTypeAs) => testGenTypeAs = VariantsBS.testConvert; -export const fortytwoOK: testGenTypeAs = $$toJS508922110[VariantsBS.fortytwoOK]; +export const fortytwoOK: testGenTypeAs = VariantsBS.fortytwoOK; export const fortytwoBAD: "fortytwo" = VariantsBS.fortytwoBAD; -export const testConvert2: (x:testGenTypeAs2) => testGenTypeAs2 = function (Arg1: any) { - const result = VariantsBS.testConvert2($$toRE508922110[Arg1]); - return $$toJS508922110[result] -}; +export const testConvert2: (x:testGenTypeAs2) => testGenTypeAs2 = VariantsBS.testConvert2; -export const testConvert3: (x:testGenTypeAs3) => testGenTypeAs3 = function (Arg1: any) { - const result = VariantsBS.testConvert3($$toRE584768163[Arg1]); - return $$toJS584768163[result] -}; +export const testConvert3: (x:testGenTypeAs3) => testGenTypeAs3 = VariantsBS.testConvert3; -export const testConvert2to3: (x:testGenTypeAs2) => testGenTypeAs3 = function (Arg1: any) { - const result = VariantsBS.testConvert2to3($$toRE508922110[Arg1]); - return $$toJS584768163[result] -}; +export const testConvert2to3: (x:testGenTypeAs2) => testGenTypeAs3 = VariantsBS.testConvert2to3; export const id1: (x:x1) => x1 = function (Arg1: any) { const result = VariantsBS.id1($$toRE930788378[Arg1]); diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.res b/jscomp/gentype_tests/typescript-react-example/src/Variants.res index 7fb6fb8f1a..c0989ffa9e 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.res @@ -31,9 +31,9 @@ let swap = x => @genType type testGenTypeAs = [ - | @genType.as("type") #type_ - | @genType.as("module") #module_ - | @genType.as("42") #fortytwo + | #type_ + | #module_ + | #fortytwo ] @genType let testConvert = (x: testGenTypeAs) => x @@ -45,9 +45,9 @@ type testGenTypeAs = [ @genType type testGenTypeAs2 = [ - | @genType.as("type") #type_ - | @genType.as("module") #module_ - | @genType.as("42") #fortytwo + | #type_ + | #module_ + | #fortytwo ] /* Since testGenTypeAs2 is the same type as testGenTypeAs1, @@ -56,9 +56,9 @@ type testGenTypeAs2 = [ @genType type testGenTypeAs3 = [ - | @genType.as("type") #type_ - | @genType.as("module") #module_ - | @genType.as("XXX THIS IS DIFFERENT") #fortytwo + | #type_ + | #module_ + | #fortytwo ] /* Since testGenTypeAs3 has a different representation: diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.bs.js b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.bs.js index 0894e9bc70..b1bd1018b8 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.bs.js @@ -52,22 +52,22 @@ function testVariantWithPayloads(x) { } function printVariantWithPayloads(x) { - if (typeof x === "number") { + if (typeof x !== "object") { console.log("printVariantWithPayloads", "A"); return ; } - switch (x.TAG | 0) { - case /* B */0 : + switch (x.TAG) { + case "B" : console.log("printVariantWithPayloads", "B(" + (String(x._0) + ")")); return ; - case /* C */1 : + case "C" : console.log("printVariantWithPayloads", "C(" + (String(x._0) + (", " + (String(x._1) + ")")))); return ; - case /* D */2 : + case "D" : var match = x._0; console.log("printVariantWithPayloads", "D((" + (String(match[0]) + (", " + (String(match[1]) + "))")))); return ; - case /* E */3 : + case "E" : console.log("printVariantWithPayloads", "E(" + (String(x._0) + (", " + (x._1 + (", " + (String(x._2) + ")")))))); return ; diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx index 6793c26c27..add9ceb111 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx @@ -2,14 +2,14 @@ /* eslint-disable import/first */ -const $$toJS13337556: { [key: string]: any } = {"0": "ARenamed"}; - -const $$toRE13337556: { [key: string]: any } = {"ARenamed": 0}; - const $$toJS346759412: { [key: string]: any } = {"0": "A", "1": "B", "2": "C"}; const $$toRE346759412: { [key: string]: any } = {"A": 0, "B": 1, "C": 2}; +const $$toJS552311971: { [key: string]: any } = {"0": "A"}; + +const $$toRE552311971: { [key: string]: any } = {"A": 0}; + // @ts-ignore: Implicit any on import import * as VariantsWithPayloadBS__Es6Import from './VariantsWithPayload.bs'; const VariantsWithPayloadBS: any = VariantsWithPayloadBS__Es6Import; @@ -37,7 +37,7 @@ export type simpleVariant = "A" | "B" | "C"; // tslint:disable-next-line:interface-over-type-literal export type variantWithPayloads = - "ARenamed" + "A" | { tag: "B"; value: number } | { tag: "C"; value: [number, number] } | { tag: "D"; value: [number, number] } @@ -71,7 +71,7 @@ export const testVariantWithPayloads: (x:variantWithPayloads) => variantWithPayl : Arg1.tag==="D" ? {TAG: 2, _0:Arg1.value} as any : {TAG: 3, _0:Arg1.value[0], _1:Arg1.value[1], _2:Arg1.value[2]} as any - : $$toRE13337556[Arg1]); + : $$toRE552311971[Arg1]); return typeof(result) === 'object' ? result.TAG===0 ? {tag:"B", value:result._0} @@ -80,7 +80,7 @@ export const testVariantWithPayloads: (x:variantWithPayloads) => variantWithPayl : result.TAG===2 ? {tag:"D", value:result._0} : {tag:"E", value:[result._0, result._1, result._2]} - : $$toJS13337556[result] + : $$toJS552311971[result] }; export const printVariantWithPayloads: (x:variantWithPayloads) => void = function (Arg1: any) { @@ -92,7 +92,7 @@ export const printVariantWithPayloads: (x:variantWithPayloads) => void = functio : Arg1.tag==="D" ? {TAG: 2, _0:Arg1.value} as any : {TAG: 3, _0:Arg1.value[0], _1:Arg1.value[1], _2:Arg1.value[2]} as any - : $$toRE13337556[Arg1]); + : $$toRE552311971[Arg1]); return result }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.res b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.res index cafe5347a7..0fc87dc5b6 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.res +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.res @@ -52,7 +52,7 @@ type simpleVariant = @genType type variantWithPayloads = - | @genType.as("ARenamed") A + | A | B(int) | C(int, int) | D((int, int)) diff --git a/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx index 9eb058b917..ba56d1cfc8 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Warnings.gen.tsx @@ -6,4 +6,4 @@ import * as WarningsBS__Es6Import from './Warnings.bs'; const WarningsBS: any = WarningsBS__Es6Import; -export const ddd: number = WarningsBS.x; +export const x: number = WarningsBS.ddd; diff --git a/jscomp/gentype_tests/typescript-react-example/src/counter.bs.js b/jscomp/gentype_tests/typescript-react-example/src/counter.bs.js index 02873b3e0b..10458c1307 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/counter.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/counter.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -var b = /* A */{ +var b = { + TAG: "A", _0: 12 }; From 3d98d22dd089233d9e6d8c7dd88975853379fb32 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 26 Mar 2023 16:42:31 +0200 Subject: [PATCH 07/20] Restore res_syntax analysis --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index d46c9c21ce..047c9a9dff 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ test-gentype: test-all: test test-gentype reanalyze: + reanalyze.exe -set-exit-code -all-cmt _build/default/res_syntax -suppress res_syntax/testrunner reanalyze.exe -set-exit-code -all-cmt _build/default/jscomp -suppress res_syntax/testrunner -exclude-paths jscomp/super_errors,jscomp/outcome_printer,jscomp/ounit_tests,jscomp/ml,jscomp/js_parser,jscomp/frontend,jscomp/ext,jscomp/depends,jscomp/core,jscomp/common,jscomp/cmij,jscomp/bsb_helper,jscomp/bsb lib: build node_modules/.bin/semver From 6681a1689985a160a211a0d828332249c51b967a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 26 Mar 2023 21:13:56 +0200 Subject: [PATCH 08/20] Remove object converter. --- jscomp/gentype/Converter.ml | 69 +------------------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index a7e72e1ba9..ef3598e868 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -5,7 +5,6 @@ type t = | CircularC of string * t | FunctionC of functionC | IdentC - | ObjectC of fieldsC | OptionC of t | PromiseC of t | TupleC of t list @@ -15,9 +14,6 @@ and groupedArgConverter = | ArgConverter of t | GroupConverter of (string * optional * t) list -and fieldC = {lblJS: string; lblRE: string; c: t} -and fieldsC = fieldC list - and functionC = { funArgConverters: groupedArgConverter list; componentName: string option; @@ -66,21 +62,6 @@ let rec toString converter = |> String.concat ", ") ^ " -> " ^ toString retConverter ^ ")" | IdentC -> "id" - | ObjectC fieldsC -> - let dot = - match converter with - | ObjectC _ -> ". " - | _ -> "" - in - "{" ^ dot - ^ (fieldsC - |> List.map (fun {lblJS; lblRE; c} -> - (match lblJS = lblRE with - | true -> lblJS - | false -> "(" ^ lblJS ^ "/" ^ lblRE ^ ")") - ^ ":" ^ (c |> toString)) - |> String.concat ", ") - ^ "}" | OptionC c -> "option(" ^ toString c ^ ")" | PromiseC c -> "promise(" ^ toString c ^ ")" | TupleC innerTypesC -> @@ -191,27 +172,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface | Nullable t -> let tConverter, tNormalized = t |> visit ~visited in (OptionC tConverter, Nullable tNormalized) - | Object (closedFlag, fields) -> - let fieldsConverted = - fields - |> List.map (fun ({type_} as field) -> (field, type_ |> visit ~visited)) - in - ( ObjectC - (fieldsConverted - |> List.map (fun ({nameJS; optional}, (converter, _)) -> - { - lblJS = nameJS; - lblRE = nameJS; - c = - (match optional = Mandatory with - | true -> converter - | false -> OptionC converter); - })), - Object - ( closedFlag, - fieldsConverted - |> List.map (fun (field, (_, tNormalized)) -> - {field with type_ = tNormalized}) ) ) + | Object _ -> (IdentC, normalized_) | Option t -> let tConverter, tNormalized = t |> visit ~visited in (OptionC tConverter, Option tNormalized) @@ -357,7 +318,6 @@ let rec converterIsIdentity ~config ~toJS converter = argConverter |> converterIsIdentity ~config ~toJS:(not toJS) | GroupConverter _ -> false) | IdentC -> true - | ObjectC _ -> true | OptionC c -> c |> converterIsIdentity ~config ~toJS | PromiseC c -> c |> converterIsIdentity ~config ~toJS | TupleC innerTypesC -> @@ -487,33 +447,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value = EmitText.funDef ~bodyArgs ~functionName:componentName ~funParams ~indent ~mkBody ~typeVars | IdentC -> value - | ObjectC fieldsC -> - let simplifyFieldConverted fieldConverter = - match fieldConverter with - | OptionC converter1 when converter1 |> converterIsIdentity ~config ~toJS - -> - IdentC - | _ -> fieldConverter - in - let fieldValues = - fieldsC - |> List.map (fun {lblJS; lblRE; c = fieldConverter} -> - (match toJS with - | true -> lblJS - | false -> lblRE) - ^ ":" - ^ (value - |> EmitText.fieldAccess - ~label: - (match toJS with - | true -> lblRE - | false -> lblJS) - |> apply ~config - ~converter:(fieldConverter |> simplifyFieldConverted) - ~indent ~nameGen ~toJS ~variantTables)) - |> String.concat ", " - in - "{" ^ fieldValues ^ "}" | OptionC c -> EmitText.parens [ From bf9984ad9b994e0479ff79f5c4a2fd9de8f974a3 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 27 Mar 2023 12:20:25 +0200 Subject: [PATCH 09/20] Remove conversion for variants. --- jscomp/gentype/Converter.ml | 221 ++---------------- jscomp/gentype/EmitJs.ml | 35 --- jscomp/gentype/EmitText.ml | 21 -- jscomp/gentype/GenTypeCommon.ml | 31 +-- jscomp/gentype/Runtime.ml | 57 ----- jscomp/gentype/Runtime.mli | 15 -- .../typescript-react-example/src/Core.gen.tsx | 13 +- .../src/Docstrings.gen.tsx | 12 +- .../src/EmitModuleIfNoConversion.gen.tsx | 11 +- .../src/ImportJsValue.gen.tsx | 9 +- .../src/Machine.gen.tsx | 2 +- .../src/MoreVariants.gen.tsx | 9 +- .../src/NestedVariants.gen.tsx | 106 ++------- .../src/Variants.gen.tsx | 49 +--- .../src/VariantsWithPayload.gen.tsx | 65 +----- .../src/counter.gen.tsx | 2 +- 16 files changed, 69 insertions(+), 589 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index ef3598e868..20d1d37b15 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -8,7 +8,6 @@ type t = | OptionC of t | PromiseC of t | TupleC of t list - | VariantC of variantC and groupedArgConverter = | ArgConverter of t @@ -23,17 +22,6 @@ and functionC = { uncurried: bool; } -and variantC = { - hash: int; - noPayloads: case list; - withPayloads: withPayload list; - polymorphic: bool; - unboxed: bool; - useVariantTables: bool; -} - -and withPayload = {case: case; inlineRecord: bool; argConverters: t list} - let rec toString converter = match converter with | ArrayC c -> "array(" ^ toString c ^ ")" @@ -66,20 +54,6 @@ let rec toString converter = | PromiseC c -> "promise(" ^ toString c ^ ")" | TupleC innerTypesC -> "[" ^ (innerTypesC |> List.map toString |> String.concat ", ") ^ "]" - | VariantC {noPayloads; withPayloads} -> - "variant(" - ^ ((noPayloads |> List.map labelJSToString) - @ (withPayloads - |> List.map (fun {case; inlineRecord; argConverters} -> - (case |> labelJSToString) - ^ (match inlineRecord with - | true -> " inlineRecord " - | false -> "") - ^ ":" ^ "{" - ^ (argConverters |> List.map toString |> String.concat ", ") - ^ "}")) - |> String.concat ", ") - ^ ")" let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface type0 = @@ -186,77 +160,33 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface (TupleC innerConversions, Tuple normalizedList) | TypeVar _ -> (IdentC, normalized_) | Variant variant -> - let allowUnboxed = not variant.polymorphic in - let withPayloads, normalized, unboxed = - match - variant.payloads - |> List.map (fun {case; inlineRecord; numArgs; t} -> - (case, inlineRecord, numArgs, t |> visit ~visited)) - with - | [] when allowUnboxed -> ([], normalized_, variant.unboxed) - | [(case, inlineRecord, numArgs, (converter, tNormalized))] - when allowUnboxed -> - let unboxed = tNormalized |> expandOneLevel |> typeIsObject in + let ordinaryVariant = not variant.polymorphic in + let withPayloadConverted = + variant.payloads + |> List.map (fun (payload : payload) -> + {payload with t = snd (payload.t |> visit ~visited)}) + in + let normalized = + match withPayloadConverted with + | [] when ordinaryVariant -> normalized_ + | [payload] when ordinaryVariant -> + let unboxed = payload.t |> expandOneLevel |> typeIsObject in let normalized = Variant { variant with - payloads = [{case; inlineRecord; numArgs; t = tNormalized}]; + payloads = [payload]; unboxed = (match unboxed with | true -> true | false -> variant.unboxed); } in - let argConverters = - match converter with - | TupleC converters when numArgs > 1 -> converters - | _ -> [converter] - in - ([{argConverters; case; inlineRecord}], normalized, unboxed) + normalized | withPayloadConverted -> - let withPayloadNormalized = - withPayloadConverted - |> List.map (fun (case, inlineRecord, numArgs, (_, tNormalized)) -> - {case; inlineRecord; numArgs; t = tNormalized}) - in - let normalized = - Variant {variant with payloads = withPayloadNormalized} - in - ( withPayloadConverted - |> List.map (fun (case, inlineRecord, numArgs, (converter, _)) -> - let argConverters = - match converter with - | TupleC converters when numArgs > 1 -> converters - | _ -> [converter] - in - {argConverters; case; inlineRecord}), - normalized, - variant.unboxed ) - in - let noPayloads = variant.noPayloads in - let useVariantTables = - if variant.bsStringOrInt then false - else if variant.polymorphic then - noPayloads - |> List.exists (fun {label; labelJS} -> labelJS <> StringLabel label) - || withPayloads - |> List.exists (fun {case = {label; labelJS}} -> - labelJS <> StringLabel label) - else true - in - let converter = - VariantC - { - hash = variant.hash; - noPayloads; - withPayloads; - polymorphic = variant.polymorphic; - unboxed; - useVariantTables; - } + Variant {variant with payloads = withPayloadConverted} in - (converter, normalized) + (IdentC, normalized) and argTypeToGroupedArgConverter ~visited {aName; aType} = match aType with | GroupOfLabeledArgs fields -> @@ -322,13 +252,6 @@ let rec converterIsIdentity ~config ~toJS converter = | PromiseC c -> c |> converterIsIdentity ~config ~toJS | TupleC innerTypesC -> innerTypesC |> List.for_all (converterIsIdentity ~config ~toJS) - | VariantC {withPayloads; useVariantTables} -> - if not useVariantTables then - withPayloads - |> List.for_all (fun {argConverters} -> - argConverters - |> List.for_all (fun c -> c |> converterIsIdentity ~config ~toJS)) - else false let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value = match converter with @@ -470,120 +393,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value = |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables) |> String.concat ", ") ^ "]" - | VariantC {noPayloads = [case]; withPayloads = []; polymorphic} -> ( - match toJS with - | true -> case |> labelJSToString - | false -> case.label |> Runtime.emitVariantLabel ~polymorphic) - | VariantC variantC -> ( - if variantC.noPayloads <> [] && variantC.useVariantTables then - Hashtbl.replace variantTables (variantC.hash, toJS) variantC; - let convertToString = - match - (not toJS) - && variantC.noPayloads - |> List.exists (fun {labelJS} -> - labelJS = BoolLabel true || labelJS = BoolLabel false) - with - | true -> ".toString()" - | false -> "" - in - let table = variantC.hash |> variantTable ~toJS in - let accessTable v = - match not variantC.useVariantTables with - | true -> v - | false -> table ^ EmitText.array [v ^ convertToString] - in - let convertVariantPayloadToJS ~indent ~argConverters x = - match argConverters with - | [converter] -> - x |> apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables - | _ -> - argConverters - |> List.mapi (fun i converter -> - x - |> Runtime.accessVariant ~index:i - |> apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables) - |> EmitText.array - in - let convertVariantPayloadToRE ~indent ~argConverters x = - match argConverters with - | [converter] -> - [x |> apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables] - | _ -> - argConverters - |> List.mapi (fun i converter -> - x - |> EmitText.arrayAccess ~index:i - |> apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables) - in - match variantC.withPayloads with - | [] -> value |> accessTable - | [{case; inlineRecord; argConverters}] when variantC.unboxed -> ( - let casesWithPayload ~indent = - if toJS then - value - |> Runtime.emitVariantGetPayload ~inlineRecord - ~numArgs:(argConverters |> List.length) - ~polymorphic:variantC.polymorphic - |> convertVariantPayloadToJS ~argConverters ~indent - else - value - |> convertVariantPayloadToRE ~argConverters ~indent - |> Runtime.emitVariantWithPayload ~inlineRecord ~label:case.label - ~polymorphic:variantC.polymorphic - in - match variantC.noPayloads = [] with - | true -> casesWithPayload ~indent - | false -> - EmitText.ifThenElse ~indent - (fun ~indent:_ -> value |> EmitText.typeOfObject) - casesWithPayload - (fun ~indent:_ -> value |> accessTable)) - | _ :: _ -> ( - let convertCaseWithPayload ~indent ~inlineRecord ~argConverters case = - if toJS then - value - |> Runtime.emitVariantGetPayload ~inlineRecord - ~numArgs:(argConverters |> List.length) - ~polymorphic:variantC.polymorphic - |> convertVariantPayloadToJS ~argConverters ~indent - |> Runtime.emitJSVariantWithPayload ~label:(case |> labelJSToString) - ~polymorphic:variantC.polymorphic - else - value - |> Runtime.emitJSVariantGetPayload ~polymorphic:variantC.polymorphic - |> convertVariantPayloadToRE ~argConverters ~indent - |> Runtime.emitVariantWithPayload ~inlineRecord ~label:case.label - ~polymorphic:variantC.polymorphic - in - let switchCases ~indent = - variantC.withPayloads - |> List.map (fun {case; inlineRecord; argConverters} -> - ( (match toJS with - | true -> - case.label - |> Runtime.emitVariantLabel ~polymorphic:variantC.polymorphic - | false -> case |> labelJSToString), - case - |> convertCaseWithPayload ~indent ~inlineRecord ~argConverters - )) - in - let casesWithPayload ~indent = - value - |> (let open Runtime in - (match toJS with - | true -> emitVariantGetLabel - | false -> emitJSVariantGetLabel) - ~polymorphic:variantC.polymorphic) - |> EmitText.switch ~indent ~cases:(switchCases ~indent) - in - match variantC.noPayloads = [] with - | true -> casesWithPayload ~indent - | false -> - EmitText.ifThenElse ~indent - (fun ~indent:_ -> value |> EmitText.typeOfObject) - casesWithPayload - (fun ~indent:_ -> value |> accessTable))) let toJS ~config ~converter ~indent ~nameGen ~variantTables value = value |> apply ~config ~converter ~indent ~nameGen ~variantTables ~toJS:true diff --git a/jscomp/gentype/EmitJs.ml b/jscomp/gentype/EmitJs.ml index 5c8bc7fb11..06b5a4d864 100644 --- a/jscomp/gentype/EmitJs.ml +++ b/jscomp/gentype/EmitJs.ml @@ -433,40 +433,6 @@ let emitRequires ~importedValueOrComponent ~early ~config ~requires emitters = ~moduleName) requires emitters -let emitVariantTables ~emitters variantTables = - let typeAnnotation = ": { [key: string]: any }" in - let emitTable ~table ~toJS (variantC : Converter.variantC) = - "const " ^ table ^ typeAnnotation ^ " = {" - ^ (variantC.noPayloads - |> List.map (fun case -> - let js = case |> labelJSToString ~alwaysQuotes:(not toJS) in - let re = - case.label - |> Runtime.emitVariantLabel ~polymorphic:variantC.polymorphic - in - match toJS with - | true -> (re |> EmitText.quotesIfRequired) ^ ": " ^ js - | false -> js ^ ": " ^ re) - |> String.concat ", ") - ^ "};" - in - Hashtbl.fold - (fun (_, toJS) variantC l -> (variantC, toJS) :: l) - variantTables [] - |> List.sort (fun (variantC1, toJS1) (variantC2, toJS2) -> - let n = compare variantC1.Converter.hash variantC2.hash in - match n <> 0 with - | true -> n - | false -> compare toJS2 toJS1) - |> List.fold_left - (fun emitters (variantC, toJS) -> - variantC - |> emitTable - ~table:(variantC.Converter.hash |> variantTable ~toJS) - ~toJS - |> Emitters.requireEarly ~emitters) - emitters - let typeGetInlined ~config ~exportTypeMap type_ = type_ |> Converter.typeGetNormalized ~config ~inline:true @@ -762,7 +728,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations | false -> env in let finalEnv = env in - let emitters = variantTables |> emitVariantTables ~emitters in let emitters = moduleItemsEmitter |> ExportModule.emitAllModuleItems ~config ~emitters ~fileName diff --git a/jscomp/gentype/EmitText.ml b/jscomp/gentype/EmitText.ml index cca2c8532e..60df74a2bb 100644 --- a/jscomp/gentype/EmitText.ml +++ b/jscomp/gentype/EmitText.ml @@ -40,32 +40,11 @@ let funDef ~bodyArgs ~functionName ~funParams ~indent ~mkBody ~typeVars = ^ genericsString ~typeVars ^ (funParams |> parens) ^ " {" ^ (bodyArgs |> mkBody) ^ Indent.break ~indent ^ "}" -let ifThenElse ~indent if_ then_ else_ = - let indent1 = indent |> Indent.more in - if_ ~indent:indent1 ^ Indent.break ~indent ^ "? " ^ then_ ~indent:indent1 - ^ Indent.break ~indent ^ ": " ^ else_ ~indent:indent1 - let newNameGen () = Hashtbl.create 1 let quotes x = "\"" ^ x ^ "\"" -let quotesIfRequired x = - match String.length x > 0 && (x.[0] [@doesNotRaise]) = '"' with - | true -> x - | false -> quotes x - let resultName ~nameGen = "result" |> name ~nameGen -let switch ~indent ~cases expr = - let lastCase = (cases |> List.length) - 1 in - cases - |> List.mapi (fun i (label, code) -> - if i = lastCase then code - else - expr ^ "===" ^ label ^ Indent.break ~indent ^ "? " ^ code - ^ Indent.break ~indent ^ ": ") - |> String.concat "" - -let typeOfObject x = "typeof(" ^ x ^ ")" ^ " === " ^ "'object'" let addComment ~comment x = "\n/* " ^ comment ^ " */\n " ^ x let arrayAccess ~index value = value ^ "[" ^ string_of_int index ^ "]" let fieldAccess ~label value = value ^ "." ^ label diff --git a/jscomp/gentype/GenTypeCommon.ml b/jscomp/gentype/GenTypeCommon.ml index ffc74372a0..d697bdc033 100644 --- a/jscomp/gentype/GenTypeCommon.ml +++ b/jscomp/gentype/GenTypeCommon.ml @@ -26,12 +26,7 @@ let isJSSafePropertyName name = | 'A' .. 'z' | '0' .. '9' -> true | _ -> false) -let labelJSToString ?(alwaysQuotes = false) case = - let addQuotes x = - match alwaysQuotes with - | true -> x |> EmitText.quotes - | false -> x - in +let labelJSToString case = let isNumber s = let len = String.length s in len > 0 @@ -48,12 +43,11 @@ let labelJSToString ?(alwaysQuotes = false) case = res.contents in match case.labelJS with - | BoolLabel b -> b |> string_of_bool |> addQuotes - | FloatLabel s -> s |> addQuotes - | IntLabel i -> i |> addQuotes + | BoolLabel b -> b |> string_of_bool + | FloatLabel s -> s + | IntLabel i -> i | StringLabel s -> - if s = case.label && isNumber s then s |> addQuotes - else s |> EmitText.quotes + if s = case.label && isNumber s then s else s |> EmitText.quotes type closedFlag = Open | Closed @@ -94,7 +88,6 @@ and ident = {builtin: bool; name: string; typeArgs: type_ list} and variant = { bsStringOrInt: bool; - hash: int; inherits: type_ list; noPayloads: case list; payloads: payload list; @@ -185,20 +178,8 @@ let rec depToResolvedName (dep : dep) = | Dot (p, s) -> ResolvedName.dot s (p |> depToResolvedName) let createVariant ~bsStringOrInt ~inherits ~noPayloads ~payloads ~polymorphic = - let hash = - noPayloads - |> List.map (fun case -> (case.label, case.labelJS)) - |> Array.of_list |> Hashtbl.hash - in let unboxed = payloads = [] in - Variant - {bsStringOrInt; hash; inherits; noPayloads; payloads; polymorphic; unboxed} - -let variantTable hash ~toJS = - (match toJS with - | true -> "$$toJS" - | false -> "$$toRE") - ^ string_of_int hash + Variant {bsStringOrInt; inherits; noPayloads; payloads; polymorphic; unboxed} let ident ?(builtin = true) ?(typeArgs = []) name = Ident {builtin; name; typeArgs} diff --git a/jscomp/gentype/Runtime.ml b/jscomp/gentype/Runtime.ml index e74ccc2803..4560419d58 100644 --- a/jscomp/gentype/Runtime.ml +++ b/jscomp/gentype/Runtime.ml @@ -24,52 +24,6 @@ let rec emitModuleAccessPath ~config moduleAccessPath = | Dot (p, moduleItem) -> p |> emitModuleAccessPath ~config |> EmitText.fieldAccess ~label:moduleItem -let emitVariantLabel ~polymorphic label = - if polymorphic then label |> EmitText.quotes else label - -module VariantsAsObjects = struct - let polyVariantLabelName = "NAME" - - let label ~polymorphic = - match polymorphic with - | true -> polyVariantLabelName - | false -> "TAG" - - let indexLabel i = "_" ^ string_of_int i -end - -let emitVariantGetLabel ~polymorphic x = - x |> EmitText.fieldAccess ~label:(VariantsAsObjects.label ~polymorphic) - -let accessVariant ~index x = - x |> EmitText.fieldAccess ~label:(index |> VariantsAsObjects.indexLabel) - -let emitVariantGetPayload ~inlineRecord ~numArgs ~polymorphic x = - if polymorphic then x |> EmitText.fieldAccess ~label:"VAL" - else if numArgs = 1 then - if inlineRecord then - (* inline record is repressented as record plus a tag: - here pass it unchanged as if it was just a record (the payload) - *) x - else x |> accessVariant ~index:0 - else (* payload items extracted later when numArgs != 1 *) x - -let emitVariantWithPayload ~inlineRecord ~label ~polymorphic args = - match args with - | [arg] when polymorphic -> - "{" ^ VariantsAsObjects.polyVariantLabelName ^ ": " - ^ (label |> emitVariantLabel ~polymorphic) - ^ ", VAL: " ^ arg ^ "}" - | [arg] when inlineRecord -> - (* inline records are represented as records plus a `TAG` *) - "Object.assign({TAG: " ^ label ^ "}, " ^ arg ^ ")" - | _ -> - "{TAG: " ^ label ^ ", " - ^ (args - |> List.mapi (fun i s -> (i |> VariantsAsObjects.indexLabel) ^ ":" ^ s) - |> String.concat ", ") - ^ "}" ^ " as any" - let jsVariantTag ~polymorphic = match polymorphic with | true -> "NAME" @@ -80,17 +34,6 @@ let jsVariantValue ~polymorphic = | true -> "VAL" | false -> "value" -let emitJSVariantGetLabel ~polymorphic x = - x |> EmitText.fieldAccess ~label:(jsVariantTag ~polymorphic) - -let emitJSVariantGetPayload ~polymorphic x = - x |> EmitText.fieldAccess ~label:(jsVariantValue ~polymorphic) - -let emitJSVariantWithPayload ~label ~polymorphic x = - "{" ^ jsVariantTag ~polymorphic ^ ":" ^ label ^ ", " - ^ jsVariantValue ~polymorphic - ^ ":" ^ x ^ "}" - let isMutableObjectField name = String.length name >= 2 && (String.sub name (String.length name - 2) 2 [@doesNotRaise]) = "#=" diff --git a/jscomp/gentype/Runtime.mli b/jscomp/gentype/Runtime.mli index 941bc62c5a..33193e8f2f 100644 --- a/jscomp/gentype/Runtime.mli +++ b/jscomp/gentype/Runtime.mli @@ -5,25 +5,10 @@ type recordValue type moduleItem type moduleAccessPath = Root of string | Dot of moduleAccessPath * moduleItem -val accessVariant : index:int -> string -> string val checkMutableObjectField : previousName:string -> name:string -> bool val default : string val emitModuleAccessPath : config:Config.t -> moduleAccessPath -> string -val emitJSVariantGetLabel : polymorphic:bool -> string -> string -val emitJSVariantGetPayload : polymorphic:bool -> string -> string -val emitJSVariantWithPayload : - label:string -> polymorphic:bool -> string -> string - -val emitVariantGetLabel : polymorphic:bool -> string -> string - -val emitVariantGetPayload : - inlineRecord:bool -> numArgs:int -> polymorphic:bool -> string -> string - -val emitVariantLabel : polymorphic:bool -> string -> string - -val emitVariantWithPayload : - inlineRecord:bool -> label:string -> polymorphic:bool -> string list -> string val isMutableObjectField : string -> bool val mangleObjectField : string -> string diff --git a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx index 8a5c6608f9..0fb5638b70 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx @@ -6,10 +6,6 @@ import {someFunWithNullThenOptionalArgs as someFunWithNullThenOptionalArgsNotChe import {someFunWithNullUndefinedArg as someFunWithNullUndefinedArgNotChecked} from './CoreTS'; -const $$toJS552311971: { [key: string]: any } = {"0": "A"}; - -const $$toRE552311971: { [key: string]: any } = {"A": 0}; - // In case of type error, check the type of 'someFunWithNullThenOptionalArgs' in 'Core.res' and './CoreTS'. export const someFunWithNullThenOptionalArgsTypeChecked: (_1:(null | string), _2:(undefined | string)) => string = someFunWithNullThenOptionalArgsNotChecked; @@ -76,11 +72,4 @@ export const weakset1: (x:WeakSet) => WeakSet = CoreBS.weaks export const option0: (x:(undefined | string)) => (undefined | string) = CoreBS.option0; -export const option1: (x:(undefined | variant)) => (undefined | variant) = function (Arg1: any) { - const result = CoreBS.option1((Arg1 == null ? Arg1 : typeof(Arg1) === 'object' - ? {TAG: 0, _0:Arg1.value} as any - : $$toRE552311971[Arg1])); - return (result == null ? result : typeof(result) === 'object' - ? {tag:"B", value:result._0} - : $$toJS552311971[result]) -}; +export const option1: (x:(undefined | variant)) => (undefined | variant) = CoreBS.option1; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx index 646ed8d367..83633212d1 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx @@ -2,8 +2,6 @@ /* eslint-disable import/first */ -const $$toJS453167283: { [key: string]: any } = {"0": "A", "1": "B"}; - // @ts-ignore: Implicit any on import import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; const Curry: any = Curry__Es6Import; @@ -63,12 +61,6 @@ export const unitArgWithoutConversion: () => string = DocstringsBS.unitArgWithou export const unitArgWithoutConversionU: () => string = DocstringsBS.unitArgWithoutConversionU; -export const unitArgWithConversion: () => t = function () { - const result = DocstringsBS.unitArgWithConversion(); - return $$toJS453167283[result] -}; +export const unitArgWithConversion: () => t = DocstringsBS.unitArgWithConversion; -export const unitArgWithConversionU: () => t = function () { - const result = DocstringsBS.unitArgWithConversionU(); - return $$toJS453167283[result] -}; +export const unitArgWithConversionU: () => t = DocstringsBS.unitArgWithConversionU; diff --git a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx index 5c7facf771..56d14b04d2 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx @@ -2,8 +2,6 @@ /* eslint-disable import/first */ -const $$toRE552311971: { [key: string]: any } = {"A": 0}; - // @ts-ignore: Implicit any on import import * as EmitModuleIfNoConversionBS__Es6Import from './EmitModuleIfNoConversion.bs'; const EmitModuleIfNoConversionBS: any = EmitModuleIfNoConversionBS__Es6Import; @@ -11,15 +9,12 @@ const EmitModuleIfNoConversionBS: any = EmitModuleIfNoConversionBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal export type t = "A" | { readonly name: string }; -export const X_foo: (t:t) => void = function (Arg1: any) { - const result = EmitModuleIfNoConversionBS.X.foo(typeof(Arg1) === 'object' - ? Object.assign({TAG: 0}, Arg1) - : $$toRE552311971[Arg1]); - return result -}; +export const X_foo: (t:t) => void = EmitModuleIfNoConversionBS.X.foo; export const X_x: number = EmitModuleIfNoConversionBS.X.x; export const Y_x: string = EmitModuleIfNoConversionBS.Y.x; export const Y: { x: string } = EmitModuleIfNoConversionBS.Y + +export const X: { x: number; foo: (t:t) => void } = EmitModuleIfNoConversionBS.X diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx index 66fda441c6..04fbdb4f52 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx @@ -70,14 +70,7 @@ export const higherOrder: unknown = function (Arg1: any) { export const convertVariantTypeChecked: (_1:variant) => variant = convertVariantNotChecked; // Export 'convertVariant' early to allow circular import from the '.bs.js' file. -export const convertVariant: unknown = function (Arg1: any) { - const result = convertVariantTypeChecked(Arg1.TAG===0 - ? {tag:"I", value:Arg1._0} - : {tag:"S", value:Arg1._0}); - return result.tag==="I" - ? {TAG: 0, _0:result.value} as any - : {TAG: 1, _0:result.value} as any -} as (_1:variant) => variant; +export const convertVariant: unknown = convertVariantTypeChecked as (_1:variant) => variant; // In case of type error, check the type of 'polymorphic' in 'ImportJsValue.res' and './MyMath'. export const polymorphicTypeChecked: (_1:a) => a = polymorphicNotChecked; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx index ab7ac50eb7..7273a7577a 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx @@ -9,4 +9,4 @@ const MachineBS: any = MachineBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal export type aa = { tag: "A"; value: number }; -export const a: aa = {tag:"A", value:MachineBS.a._0}; +export const a: aa = MachineBS.a; diff --git a/jscomp/gentype_tests/typescript-react-example/src/MoreVariants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/MoreVariants.gen.tsx index ae2339a5e8..5d11efc9ee 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/MoreVariants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/MoreVariants.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -const $$toJS912209123: { [key: string]: any } = {"type_": "type", "b": "b"}; - -const $$toRE912209123: { [key: string]: any } = {"type": "type_", "b": "b"}; - // @ts-ignore: Implicit any on import import * as MoreVariantsBS__Es6Import from './MoreVariants.bs'; const MoreVariantsBS: any = MoreVariantsBS__Es6Import; @@ -16,9 +12,6 @@ export type withRenaming = "type" | "b"; // tslint:disable-next-line:interface-over-type-literal export type withoutRenaming = "type_" | "b"; -export const testWithRenaming: (x:withRenaming) => withRenaming = function (Arg1: any) { - const result = MoreVariantsBS.testWithRenaming($$toRE912209123[Arg1]); - return $$toJS912209123[result] -}; +export const testWithRenaming: (x:withRenaming) => withRenaming = MoreVariantsBS.testWithRenaming; export const testWithoutRenaming: (x:withoutRenaming) => withoutRenaming = MoreVariantsBS.testWithoutRenaming; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx index bc3d729a61..dfeb837c8d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx @@ -58,90 +58,28 @@ export type inline = | { tag: "J"; value: { readonly i: number; readonly j: number } } | { tag: "K"; value: [number, number] }; -export const makeVariant: () => typeL = function () { - const result = NestedVariantsBS.makeVariant(); - return [result._0, result._1] -}; - -export const makeABC: () => typeA = function () { - const result = NestedVariantsBS.makeABC(); - return result.TAG===0 - ? {tag:"A", value:[result._0, result._1]} - : {tag:"B", value:[result._0, result._1]} -}; +export const makeVariant: () => typeL = NestedVariantsBS.makeVariant; + +export const makeABC: () => typeA = NestedVariantsBS.makeABC; export const makeBC: () => typeB = NestedVariantsBS.makeBC; -export const makeAC: () => typeA = function () { - const result = NestedVariantsBS.makeAC(); - return result.TAG===0 - ? {tag:"A", value:[result._0.TAG===0 - ? {tag:"C", value:result._0._0} - : {tag:"D", value:result._0._0}, result._1]} - : {tag:"B", value:[result._0.TAG===0 - ? {tag:"C", value:result._0._0} - : {tag:"D", value:result._0._0}, result._1]} -}; - -export const makeAD: () => typeA = function () { - const result = NestedVariantsBS.makeAD(); - return result.TAG===0 - ? {tag:"A", value:[{tag:"Int", value:result._0._0}, result._1]} - : {tag:"B", value:[{tag:"Int", value:result._0._0}, result._1]} -}; - -export const makeAE: () => typeA = function () { - const result = NestedVariantsBS.makeAE(); - return result.TAG===0 - ? {tag:"A", value:[result._0, result._1]} - : {tag:"B", value:[result._0, result._1]} -}; - -export const makeFD: () => typeF = function () { - const result = NestedVariantsBS.makeFD(); - return result.TAG===0 - ? {tag:"F", value:{tag:"Int", value:result._0._0}} - : {tag:"G", value:{tag:"Int", value:result._0._0}} -}; - -export const makeHD: () => typeH = function () { - const result = NestedVariantsBS.makeHD(); - return result.TAG===0 - ? {tag:"H", value:[{tag:"Int", value:result._0._0}, result._1]} - : {tag:"I", value:[{tag:"Int", value:result._0._0}, result._1]} -}; - -export const makeJ: () => typeJ = function () { - const result = NestedVariantsBS.makeJ(); - return [{tag:"Int", value:result._0._0}, {tag:"Int", value:result._1._0}] -}; - -export const makeK: () => typeK = function () { - const result = NestedVariantsBS.makeK(); - return [{tag:"Int", value:result._0[0]._0}, {tag:"Int", value:result._0[1]._0}] -}; - -export const testBoxedBinary: (param:boxedBinary) => number = function (Arg1: any) { - const result = NestedVariantsBS.testBoxedBinary(Arg1.tag==="BB" - ? {TAG: 0, _0:{TAG: 0, _0:Arg1.value[0].value} as any, _1:Arg1.value[1]} as any - : {TAG: 1, _0:Arg1.value} as any); - return result -}; - -export const testUnboxedBinary: (param:unboxedBinary) => number = function (Arg1: any) { - const result = NestedVariantsBS.testUnboxedBinary({TAG: 0, _0:{TAG: 0, _0:Arg1[0].value} as any, _1:Arg1[1]} as any); - return result -}; - -export const testInline: (x:inline) => inline = function (Arg1: any) { - const result = NestedVariantsBS.testInline(Arg1.tag==="I" - ? Object.assign({TAG: 0}, Arg1.value) - : Arg1.tag==="J" - ? Object.assign({TAG: 1}, Arg1.value) - : {TAG: 2, _0:Arg1.value[0], _1:Arg1.value[1]} as any); - return result.TAG===0 - ? {tag:"I", value:result} - : result.TAG===1 - ? {tag:"J", value:result} - : {tag:"K", value:[result._0, result._1]} -}; +export const makeAC: () => typeA = NestedVariantsBS.makeAC; + +export const makeAD: () => typeA = NestedVariantsBS.makeAD; + +export const makeAE: () => typeA = NestedVariantsBS.makeAE; + +export const makeFD: () => typeF = NestedVariantsBS.makeFD; + +export const makeHD: () => typeH = NestedVariantsBS.makeHD; + +export const makeJ: () => typeJ = NestedVariantsBS.makeJ; + +export const makeK: () => typeK = NestedVariantsBS.makeK; + +export const testBoxedBinary: (param:boxedBinary) => number = NestedVariantsBS.testBoxedBinary; + +export const testUnboxedBinary: (param:unboxedBinary) => number = NestedVariantsBS.testUnboxedBinary; + +export const testInline: (x:inline) => inline = NestedVariantsBS.testInline; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx index efa3c07cd5..9f59cf6c65 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx @@ -2,14 +2,6 @@ /* eslint-disable import/first */ -const $$toJS930788378: { [key: string]: any } = {"x": "x", "x1": "same"}; - -const $$toRE930788378: { [key: string]: any } = {"x": "x", "same": "x1"}; - -const $$toJS1061900109: { [key: string]: any } = {"x": "x", "x2": "same"}; - -const $$toRE1061900109: { [key: string]: any } = {"x": "x", "same": "x2"}; - // @ts-ignore: Implicit any on import import * as VariantsBS__Es6Import from './Variants.bs'; const VariantsBS: any = VariantsBS__Es6Import; @@ -82,43 +74,16 @@ export const testConvert3: (x:testGenTypeAs3) => testGenTypeAs3 = VariantsBS.tes export const testConvert2to3: (x:testGenTypeAs2) => testGenTypeAs3 = VariantsBS.testConvert2to3; -export const id1: (x:x1) => x1 = function (Arg1: any) { - const result = VariantsBS.id1($$toRE930788378[Arg1]); - return $$toJS930788378[result] -}; +export const id1: (x:x1) => x1 = VariantsBS.id1; -export const id2: (x:x2) => x2 = function (Arg1: any) { - const result = VariantsBS.id2($$toRE1061900109[Arg1]); - return $$toJS1061900109[result] -}; +export const id2: (x:x2) => x2 = VariantsBS.id2; export const polyWithOpt: (foo:string) => (undefined | ( { NAME: "One"; VAL: string } | { NAME: "Two"; VAL: number })) = VariantsBS.polyWithOpt; -export const restResult1: (x:result1) => result1 = function (Arg1: any) { - const result = VariantsBS.restResult1(Arg1.tag==="Ok" - ? {TAG: 0, _0:Arg1.value} as any - : {TAG: 1, _0:Arg1.value} as any); - return result.TAG===0 - ? {tag:"Ok", value:result._0} - : {tag:"Error", value:result._0} -}; - -export const restResult2: (x:result2) => result2 = function (Arg1: any) { - const result = VariantsBS.restResult2(Arg1.tag==="Ok" - ? {TAG: 0, _0:Arg1.value} as any - : {TAG: 1, _0:Arg1.value} as any); - return result.TAG===0 - ? {tag:"Ok", value:result._0} - : {tag:"Error", value:result._0} -}; - -export const restResult3: (x:result3) => result3 = function (Arg1: any) { - const result = VariantsBS.restResult3(Arg1.tag==="Ok" - ? {TAG: 0, _0:Arg1.value} as any - : {TAG: 1, _0:Arg1.value} as any); - return result.TAG===0 - ? {tag:"Ok", value:result._0} - : {tag:"Error", value:result._0} -}; +export const restResult1: (x:result1) => result1 = VariantsBS.restResult1; + +export const restResult2: (x:result2) => result2 = VariantsBS.restResult2; + +export const restResult3: (x:result3) => result3 = VariantsBS.restResult3; diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx index add9ceb111..77065e9f56 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx @@ -2,14 +2,6 @@ /* eslint-disable import/first */ -const $$toJS346759412: { [key: string]: any } = {"0": "A", "1": "B", "2": "C"}; - -const $$toRE346759412: { [key: string]: any } = {"A": 0, "B": 1, "C": 2}; - -const $$toJS552311971: { [key: string]: any } = {"0": "A"}; - -const $$toRE552311971: { [key: string]: any } = {"A": 0}; - // @ts-ignore: Implicit any on import import * as VariantsWithPayloadBS__Es6Import from './VariantsWithPayload.bs'; const VariantsWithPayloadBS: any = VariantsWithPayloadBS__Es6Import; @@ -57,51 +49,12 @@ export const testManyPayloads: (x:manyPayloads) => manyPayloads = VariantsWithPa export const printManyPayloads: (x:manyPayloads) => void = VariantsWithPayloadBS.printManyPayloads; -export const testSimpleVariant: (x:simpleVariant) => simpleVariant = function (Arg1: any) { - const result = VariantsWithPayloadBS.testSimpleVariant($$toRE346759412[Arg1]); - return $$toJS346759412[result] -}; - -export const testVariantWithPayloads: (x:variantWithPayloads) => variantWithPayloads = function (Arg1: any) { - const result = VariantsWithPayloadBS.testVariantWithPayloads(typeof(Arg1) === 'object' - ? Arg1.tag==="B" - ? {TAG: 0, _0:Arg1.value} as any - : Arg1.tag==="C" - ? {TAG: 1, _0:Arg1.value[0], _1:Arg1.value[1]} as any - : Arg1.tag==="D" - ? {TAG: 2, _0:Arg1.value} as any - : {TAG: 3, _0:Arg1.value[0], _1:Arg1.value[1], _2:Arg1.value[2]} as any - : $$toRE552311971[Arg1]); - return typeof(result) === 'object' - ? result.TAG===0 - ? {tag:"B", value:result._0} - : result.TAG===1 - ? {tag:"C", value:[result._0, result._1]} - : result.TAG===2 - ? {tag:"D", value:result._0} - : {tag:"E", value:[result._0, result._1, result._2]} - : $$toJS552311971[result] -}; - -export const printVariantWithPayloads: (x:variantWithPayloads) => void = function (Arg1: any) { - const result = VariantsWithPayloadBS.printVariantWithPayloads(typeof(Arg1) === 'object' - ? Arg1.tag==="B" - ? {TAG: 0, _0:Arg1.value} as any - : Arg1.tag==="C" - ? {TAG: 1, _0:Arg1.value[0], _1:Arg1.value[1]} as any - : Arg1.tag==="D" - ? {TAG: 2, _0:Arg1.value} as any - : {TAG: 3, _0:Arg1.value[0], _1:Arg1.value[1], _2:Arg1.value[2]} as any - : $$toRE552311971[Arg1]); - return result -}; - -export const testVariant1Int: (x:variant1Int) => variant1Int = function (Arg1: any) { - const result = VariantsWithPayloadBS.testVariant1Int({TAG: 0, _0:Arg1.value} as any); - return {tag:"R", value:result._0} -}; - -export const testVariant1Object: (x:variant1Object) => variant1Object = function (Arg1: any) { - const result = VariantsWithPayloadBS.testVariant1Object({TAG: 0, _0:Arg1} as any); - return result._0 -}; +export const testSimpleVariant: (x:simpleVariant) => simpleVariant = VariantsWithPayloadBS.testSimpleVariant; + +export const testVariantWithPayloads: (x:variantWithPayloads) => variantWithPayloads = VariantsWithPayloadBS.testVariantWithPayloads; + +export const printVariantWithPayloads: (x:variantWithPayloads) => void = VariantsWithPayloadBS.printVariantWithPayloads; + +export const testVariant1Int: (x:variant1Int) => variant1Int = VariantsWithPayloadBS.testVariant1Int; + +export const testVariant1Object: (x:variant1Object) => variant1Object = VariantsWithPayloadBS.testVariant1Object; diff --git a/jscomp/gentype_tests/typescript-react-example/src/counter.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/counter.gen.tsx index 64cbda543c..58a59a93e3 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/counter.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/counter.gen.tsx @@ -8,4 +8,4 @@ const counterBS: any = counterBS__Es6Import; import type {aa as Machine_aa} from './Machine.gen'; -export const b: Machine_aa = {tag:"A", value:counterBS.b._0}; +export const b: Machine_aa = counterBS.b; From 388db47ff329d6ae83dc8857f7117adb5a41c174 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 05:07:53 +0200 Subject: [PATCH 10/20] Emit the correct type for the variants runtime representation. --- jscomp/gentype/EmitType.ml | 37 +++++++++++++++---- jscomp/gentype/Runtime.ml | 4 +- jscomp/gentype/Runtime.mli | 2 +- .../src/AutoAnnotate.gen.tsx | 6 +-- .../typescript-react-example/src/Core.gen.tsx | 2 +- .../src/ImportJsValue.gen.tsx | 4 +- .../src/Machine.gen.tsx | 2 +- .../src/NestedModules.gen.tsx | 2 +- .../src/NestedVariants.gen.tsx | 28 +++++++------- .../src/Variants.gen.tsx | 16 ++++---- .../typescript-react-example/src/Variants.res | 8 ++-- .../src/VariantsWithPayload.gen.tsx | 10 ++--- .../typescript-react-example/src/index.tsx | 14 +++---- .../src/nested/Types.gen.tsx | 4 +- 14 files changed, 80 insertions(+), 59 deletions(-) diff --git a/jscomp/gentype/EmitType.ml b/jscomp/gentype/EmitType.ml index d8f38ff5e2..0c43247c4d 100644 --- a/jscomp/gentype/EmitType.ml +++ b/jscomp/gentype/EmitType.ml @@ -191,20 +191,41 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface let payloadsRendered = payloads |> List.map (fun {case; t = type_} -> - let typeRendered = - type_ - |> renderType ~config ~indent ~typeNameIsInterface ~inFunType + let render t = + t |> renderType ~config ~indent ~typeNameIsInterface ~inFunType in - match unboxed with - | true -> typeRendered - | false -> + let tagField = + case |> labelJSToString + |> field ~name:(Runtime.jsVariantTag ~polymorphic:false) + in + match (unboxed, type_) with + | true, type_ -> type_ |> render + | false, type_ when polymorphic -> + (* poly variant *) [ case |> labelJSToString |> field ~name:(Runtime.jsVariantTag ~polymorphic); - typeRendered + type_ |> render |> field ~name:(Runtime.jsVariantValue ~polymorphic); ] - |> fields) + |> fields + | false, Object (_, flds) -> + (* inlined record *) + tagField :: flds |> fields + | false, type_ -> + (* ordinary variant *) + let payloads = + match type_ with + | Tuple ts -> ts + | _ -> [type_] + in + let flds = + tagField + :: Ext_list.mapi payloads (fun n t -> + t |> render + |> field ~name:(Runtime.jsVariantPayloadTag ~n)) + in + flds |> fields) in let rendered = inheritsRendered @ noPayloadsRendered @ payloadsRendered in let indent1 = rendered |> Indent.heuristicVariants ~indent in diff --git a/jscomp/gentype/Runtime.ml b/jscomp/gentype/Runtime.ml index 4560419d58..9fef385103 100644 --- a/jscomp/gentype/Runtime.ml +++ b/jscomp/gentype/Runtime.ml @@ -27,7 +27,9 @@ let rec emitModuleAccessPath ~config moduleAccessPath = let jsVariantTag ~polymorphic = match polymorphic with | true -> "NAME" - | false -> "tag" + | false -> "TAG" + +let jsVariantPayloadTag ~n = "_" ^ string_of_int n let jsVariantValue ~polymorphic = match polymorphic with diff --git a/jscomp/gentype/Runtime.mli b/jscomp/gentype/Runtime.mli index 33193e8f2f..43867f5e35 100644 --- a/jscomp/gentype/Runtime.mli +++ b/jscomp/gentype/Runtime.mli @@ -9,7 +9,6 @@ val checkMutableObjectField : previousName:string -> name:string -> bool val default : string val emitModuleAccessPath : config:Config.t -> moduleAccessPath -> string - val isMutableObjectField : string -> bool val mangleObjectField : string -> string val newModuleItem : name:string -> moduleItem @@ -17,4 +16,5 @@ val newRecordValue : unboxed:bool -> recordGen -> recordValue val recordGen : unit -> recordGen val recordValueToString : recordValue -> string val jsVariantTag : polymorphic:bool -> string +val jsVariantPayloadTag : n:int -> string val jsVariantValue : polymorphic:bool -> string diff --git a/jscomp/gentype_tests/typescript-react-example/src/AutoAnnotate.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/AutoAnnotate.gen.tsx index b5bd5bca66..88f99dbf1d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/AutoAnnotate.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/AutoAnnotate.gen.tsx @@ -3,7 +3,7 @@ // tslint:disable-next-line:interface-over-type-literal -export type variant = { tag: "R"; value: number }; +export type variant = { TAG: "R"; _0: number }; // tslint:disable-next-line:interface-over-type-literal export type record = { readonly variant: variant }; @@ -19,5 +19,5 @@ export type r4 = { readonly r4: number }; // tslint:disable-next-line:interface-over-type-literal export type annotatedVariant = - { tag: "R2"; value: [r2, r3] } - | { tag: "R4"; value: r4 }; + { TAG: "R2"; _0: r2; _1: r3 } + | { TAG: "R4"; _0: r4 }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx index 0fb5638b70..17b7dc2685 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Core.gen.tsx @@ -22,7 +22,7 @@ export const someFunWithNullUndefinedArg: unknown = someFunWithNullUndefinedArgT const CoreBS = require('./Core.bs'); // tslint:disable-next-line:interface-over-type-literal -export type variant = "A" | { tag: "B"; value: string }; +export type variant = "A" | { TAG: "B"; _0: string }; // tslint:disable-next-line:interface-over-type-literal export type t1 = { readonly x?: string }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx index 04fbdb4f52..7630e3a4df 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx @@ -116,8 +116,8 @@ export type color = "tomato" | "gray"; // tslint:disable-next-line:interface-over-type-literal export type variant = - { tag: "I"; value: number } - | { tag: "S"; value: string }; + { TAG: "I"; _0: number } + | { TAG: "S"; _0: string }; // tslint:disable-next-line:interface-over-type-literal export type num = $$num; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx index 7273a7577a..da11ae974b 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Machine.gen.tsx @@ -7,6 +7,6 @@ import * as MachineBS__Es6Import from './Machine.bs'; const MachineBS: any = MachineBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal -export type aa = { tag: "A"; value: number }; +export type aa = { TAG: "A"; _0: number }; export const a: aa = MachineBS.a; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedModules.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/NestedModules.gen.tsx index 37cbfabaff..8a58e86616 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedModules.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedModules.gen.tsx @@ -16,7 +16,7 @@ export type Universe_Nested2_nested2Type = Array; export type Universe_Nested2_Nested3_nested3Type = Array>; // tslint:disable-next-line:interface-over-type-literal -export type Universe_variant = "A" | { tag: "B"; value: string }; +export type Universe_variant = "A" | { TAG: "B"; _0: string }; export const notNested: number = NestedModulesBS.notNested; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx index dfeb837c8d..1389734480 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx @@ -11,32 +11,30 @@ export type typeL = [number, number]; // tslint:disable-next-line:interface-over-type-literal export type typeC = - { tag: "C"; value: string } - | { tag: "D"; value: string }; + { TAG: "C"; _0: string } + | { TAG: "D"; _0: string }; // tslint:disable-next-line:interface-over-type-literal export type typeB = { readonly c: typeC }; // tslint:disable-next-line:interface-over-type-literal -export type typeD = { tag: "Int"; value: number }; +export type typeD = { TAG: "Int"; _0: number }; // tslint:disable-next-line:interface-over-type-literal export type typeE = number; // tslint:disable-next-line:interface-over-type-literal export type typeA = - { tag: "A"; value: [a, number] } - | { tag: "B"; value: [a, number] }; + { TAG: "A"; _0: a; _1: number } + | { TAG: "B"; _0: a; _1: number }; // tslint:disable-next-line:interface-over-type-literal -export type typeF = - { tag: "F"; value: a } - | { tag: "G"; value: a }; +export type typeF = { TAG: "F"; _0: a } | { TAG: "G"; _0: a }; // tslint:disable-next-line:interface-over-type-literal export type typeH = - { tag: "H"; value: [typeD, number] } - | { tag: "I"; value: [typeD, number] }; + { TAG: "H"; _0: typeD; _1: number } + | { TAG: "I"; _0: typeD; _1: number }; // tslint:disable-next-line:interface-over-type-literal export type typeJ = [typeD, typeD]; @@ -46,17 +44,17 @@ export type typeK = [typeD, typeD]; // tslint:disable-next-line:interface-over-type-literal export type boxedBinary = - { tag: "BB"; value: [typeD, number] } - | { tag: "Z"; value: number }; + { TAG: "BB"; _0: typeD; _1: number } + | { TAG: "Z"; _0: number }; // tslint:disable-next-line:interface-over-type-literal export type unboxedBinary = [typeD, number]; // tslint:disable-next-line:interface-over-type-literal export type inline = - { tag: "I"; value: { readonly i: number; readonly j: number } } - | { tag: "J"; value: { readonly i: number; readonly j: number } } - | { tag: "K"; value: [number, number] }; + { TAG: "I"; readonly i: number; readonly j: number } + | { TAG: "J"; readonly i: number; readonly j: number } + | { TAG: "K"; _0: number; _1: number }; export const makeVariant: () => typeL = NestedVariantsBS.makeVariant; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx index 9f59cf6c65..c5d5f0b5b5 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx @@ -20,10 +20,10 @@ export type weekday = export type testGenTypeAs = "type_" | "module_" | "fortytwo"; // tslint:disable-next-line:interface-over-type-literal -export type testGenTypeAs2 = "type_" | "module_" | "fortytwo"; +export type testGenTypeAs2 = "type_" | "module" | 42; // tslint:disable-next-line:interface-over-type-literal -export type testGenTypeAs3 = "type_" | "module_" | "fortytwo"; +export type testGenTypeAs3 = "type_" | "module" | 42; // tslint:disable-next-line:interface-over-type-literal export type x1 = "x" | "same"; @@ -37,18 +37,18 @@ export type type = type_; // tslint:disable-next-line:interface-over-type-literal export type result1 = - { tag: "Ok"; value: a } - | { tag: "Error"; value: b }; + { TAG: "Ok"; _0: a } + | { TAG: "Error"; _0: b }; // tslint:disable-next-line:interface-over-type-literal export type result2 = - { tag: "Ok"; value: a } - | { tag: "Error"; value: b }; + { TAG: "Ok"; _0: a } + | { TAG: "Error"; _0: b }; // tslint:disable-next-line:interface-over-type-literal export type result3 = - { tag: "Ok"; value: a } - | { tag: "Error"; value: b }; + { TAG: "Ok"; _0: a } + | { TAG: "Error"; _0: b }; export const isWeekend: (x:weekday) => boolean = VariantsBS.isWeekend; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.res b/jscomp/gentype_tests/typescript-react-example/src/Variants.res index c0989ffa9e..9dcb2a491b 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.res @@ -46,8 +46,8 @@ type testGenTypeAs = [ @genType type testGenTypeAs2 = [ | #type_ - | #module_ - | #fortytwo + | #\"module" + | #42 ] /* Since testGenTypeAs2 is the same type as testGenTypeAs1, @@ -57,8 +57,8 @@ type testGenTypeAs2 = [ @genType type testGenTypeAs3 = [ | #type_ - | #module_ - | #fortytwo + | #\"module" + | #42 ] /* Since testGenTypeAs3 has a different representation: diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx index 77065e9f56..4862fcfcd9 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx @@ -30,13 +30,13 @@ export type simpleVariant = "A" | "B" | "C"; // tslint:disable-next-line:interface-over-type-literal export type variantWithPayloads = "A" - | { tag: "B"; value: number } - | { tag: "C"; value: [number, number] } - | { tag: "D"; value: [number, number] } - | { tag: "E"; value: [number, string, number] }; + | { TAG: "B"; _0: number } + | { TAG: "C"; _0: number; _1: number } + | { TAG: "D"; _0: number; _1: number } + | { TAG: "E"; _0: number; _1: string; _2: number }; // tslint:disable-next-line:interface-over-type-literal -export type variant1Int = { tag: "R"; value: number }; +export type variant1Int = { TAG: "R"; _0: number }; // tslint:disable-next-line:interface-over-type-literal export type variant1Object = payload; diff --git a/jscomp/gentype_tests/typescript-react-example/src/index.tsx b/jscomp/gentype_tests/typescript-react-example/src/index.tsx index 9b209c8cf1..179abad72d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/index.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/index.tsx @@ -90,8 +90,8 @@ consoleLog( Variants.testConvert2to3('module') ); consoleLog( - "Variants: testConvert3to2('42') =", - Variants.testConvert2to3('42') + "Variants: testConvert3to2(42) =", + Variants.testConvert2to3(42) ); const absoluteValueInstance = new MyMath.AbsoluteValue(); @@ -114,12 +114,12 @@ printManyPayloads({ NAME: "one", VAL: 34 }); printManyPayloads({ NAME: "two", VAL: ["hello", "world"] }); printManyPayloads(testManyPayloads({ NAME: "three", VAL: { x: 15 } })); -printVariantWithPayloads(testVariantWithPayloads("ARenamed")); -printVariantWithPayloads(testVariantWithPayloads({ tag: "B", value: 4 })); -printVariantWithPayloads(testVariantWithPayloads({ tag: "C", value: [1, 2] })); -printVariantWithPayloads(testVariantWithPayloads({ tag: "D", value: [1, 2] })); +printVariantWithPayloads(testVariantWithPayloads("A")); +printVariantWithPayloads(testVariantWithPayloads({ TAG: "B", _0: 4 })); +printVariantWithPayloads(testVariantWithPayloads({ TAG: "C", _0:1, _1:2 })); +printVariantWithPayloads(testVariantWithPayloads({ TAG: "D", _0:1, _1:2 })); printVariantWithPayloads( - testVariantWithPayloads({ tag: "E", value: [1, "hello", 2] }) + testVariantWithPayloads({ TAG: "E", _0:1, _1:"hello", _2:2 }) ); TestPromise.convert(Promise.resolve({ x: 3, s: "hello" })).then((x) => diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx index 3195af09e6..3549157d62 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx @@ -25,8 +25,8 @@ export type t = number; // tslint:disable-next-line:interface-over-type-literal export type typeWithVars = - { tag: "A"; value: [x, y] } - | { tag: "B"; value: z }; + { TAG: "A"; _0: x; _1: y } + | { TAG: "B"; _0: z }; // tslint:disable-next-line:interface-over-type-literal export type tree = { From 148829d4ff502b68f37f07f801a0ff3f04722af9 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 05:15:12 +0200 Subject: [PATCH 11/20] Don't auto unbox variants with 1 payload. --- jscomp/gentype/Converter.ml | 14 ++------------ .../src/EmitModuleIfNoConversion.gen.tsx | 2 +- .../src/NestedVariants.gen.tsx | 9 +++++---- .../src/VariantsWithPayload.gen.tsx | 2 +- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 20d1d37b15..312e7be1bb 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -170,18 +170,8 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface match withPayloadConverted with | [] when ordinaryVariant -> normalized_ | [payload] when ordinaryVariant -> - let unboxed = payload.t |> expandOneLevel |> typeIsObject in - let normalized = - Variant - { - variant with - payloads = [payload]; - unboxed = - (match unboxed with - | true -> true - | false -> variant.unboxed); - } - in + let _unboxed = payload.t |> expandOneLevel |> typeIsObject in + let normalized = Variant {variant with payloads = [payload]} in normalized | withPayloadConverted -> Variant {variant with payloads = withPayloadConverted} diff --git a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx index 56d14b04d2..0c8dc66e78 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.gen.tsx @@ -7,7 +7,7 @@ import * as EmitModuleIfNoConversionBS__Es6Import from './EmitModuleIfNoConversi const EmitModuleIfNoConversionBS: any = EmitModuleIfNoConversionBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal -export type t = "A" | { readonly name: string }; +export type t = "A" | { TAG: "B"; readonly name: string }; export const X_foo: (t:t) => void = EmitModuleIfNoConversionBS.X.foo; diff --git a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx index 1389734480..6d33f6cfce 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/NestedVariants.gen.tsx @@ -7,7 +7,8 @@ import * as NestedVariantsBS__Es6Import from './NestedVariants.bs'; const NestedVariantsBS: any = NestedVariantsBS__Es6Import; // tslint:disable-next-line:interface-over-type-literal -export type typeL = [number, number]; +export type typeL = + { TAG: "NonUnary"; _0: number; _1: number }; // tslint:disable-next-line:interface-over-type-literal export type typeC = @@ -37,10 +38,10 @@ export type typeH = | { TAG: "I"; _0: typeD; _1: number }; // tslint:disable-next-line:interface-over-type-literal -export type typeJ = [typeD, typeD]; +export type typeJ = { TAG: "J"; _0: typeD; _1: typeD }; // tslint:disable-next-line:interface-over-type-literal -export type typeK = [typeD, typeD]; +export type typeK = { TAG: "K"; _0: typeD; _1: typeD }; // tslint:disable-next-line:interface-over-type-literal export type boxedBinary = @@ -48,7 +49,7 @@ export type boxedBinary = | { TAG: "Z"; _0: number }; // tslint:disable-next-line:interface-over-type-literal -export type unboxedBinary = [typeD, number]; +export type unboxedBinary = { TAG: "UB"; _0: typeD; _1: number }; // tslint:disable-next-line:interface-over-type-literal export type inline = diff --git a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx index 4862fcfcd9..4420b28595 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/VariantsWithPayload.gen.tsx @@ -39,7 +39,7 @@ export type variantWithPayloads = export type variant1Int = { TAG: "R"; _0: number }; // tslint:disable-next-line:interface-over-type-literal -export type variant1Object = payload; +export type variant1Object = { TAG: "R"; _0: payload }; export const testWithPayload: (x:withPayload) => withPayload = VariantsWithPayloadBS.testWithPayload; From 22a4ba50151175eba3a782f9482ae3132c08fb8f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 05:24:50 +0200 Subject: [PATCH 12/20] Refactor. --- jscomp/gentype/Converter.ml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 312e7be1bb..03a26c3111 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -58,14 +58,6 @@ let rec toString converter = let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface type0 = let circular = ref "" in - let expandOneLevel type_ = - match type_ with - | Ident {builtin = false; name} -> ( - match name |> lookupId with - | (t : CodeItem.exportTypeItem) -> t.type_ - | exception Not_found -> type_) - | _ -> type_ - in let rec visit ~(visited : StringSet.t) type_ = let normalized_ = type_ in match type_ with @@ -111,9 +103,8 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface circular := name; (IdentC, normalized_)) else - let visited = visited |> StringSet.add name in match name |> lookupId with - | {annotation = GenTypeOpaque} -> (IdentC, normalized_) + | {CodeItem.annotation = GenTypeOpaque} -> (IdentC, normalized_) | {annotation = NoGenType} -> (IdentC, normalized_) | {typeVars; type_} -> ( let pairs = @@ -170,7 +161,6 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface match withPayloadConverted with | [] when ordinaryVariant -> normalized_ | [payload] when ordinaryVariant -> - let _unboxed = payload.t |> expandOneLevel |> typeIsObject in let normalized = Variant {variant with payloads = [payload]} in normalized | withPayloadConverted -> From 568a0fbd1866a6951a1881dc27c1384047691151 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 05:28:28 +0200 Subject: [PATCH 13/20] Remove array converter --- jscomp/gentype/Converter.ml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 03a26c3111..f4306db886 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,7 +1,6 @@ open GenTypeCommon type t = - | ArrayC of t | CircularC of string * t | FunctionC of functionC | IdentC @@ -24,7 +23,6 @@ and functionC = { let rec toString converter = match converter with - | ArrayC c -> "array(" ^ toString c ^ ")" | CircularC (s, c) -> "circular(" ^ s ^ " " ^ toString c ^ ")" | FunctionC {funArgConverters; retConverter; uncurried} -> "fn" @@ -62,8 +60,8 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface let normalized_ = type_ in match type_ with | Array (t, mutable_) -> - let tConverter, tNormalized = t |> visit ~visited in - (ArrayC tConverter, Array (tNormalized, mutable_)) + let _, tNormalized = t |> visit ~visited in + (IdentC, Array (tNormalized, mutable_)) | Dict _ -> (IdentC, normalized_) | Function ({argTypes; componentName; retType; typeVars; uncurried} as function_) @@ -216,7 +214,6 @@ let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = let rec converterIsIdentity ~config ~toJS converter = match converter with - | ArrayC c -> c |> converterIsIdentity ~config ~toJS | CircularC (_, c) -> c |> converterIsIdentity ~config ~toJS | FunctionC {funArgConverters; retConverter; uncurried} -> retConverter |> converterIsIdentity ~config ~toJS @@ -233,16 +230,10 @@ let rec converterIsIdentity ~config ~toJS converter = | TupleC innerTypesC -> innerTypesC |> List.for_all (converterIsIdentity ~config ~toJS) -let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value = +let rec apply ~(config : Config.t) ~converter ~indent ~nameGen ~toJS + ~variantTables value = match converter with | _ when converter |> converterIsIdentity ~config ~toJS -> value - | ArrayC c -> - let x = "ArrayItem" |> EmitText.name ~nameGen in - value ^ ".map(function _element(" - ^ (x |> EmitType.ofTypeAny ~config) - ^ ") { return " - ^ (x |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables) - ^ "})" | CircularC (s, c) -> value |> EmitText.addComment From 57e546c719fea7a143a2ded76f4674489f5f529c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 05:34:49 +0200 Subject: [PATCH 14/20] Remove function converter. --- jscomp/gentype/Converter.ml | 165 +----------------- jscomp/gentype/EmitText.ml | 23 --- jscomp/gentype/GenTypeCommon.ml | 16 -- .../src/Docstrings.gen.tsx | 24 +-- .../src/Hooks.gen.tsx | 19 +- .../src/ImportHooks.gen.tsx | 5 +- .../src/ImportJsValue.gen.tsx | 12 +- .../src/Records.gen.tsx | 9 +- .../src/References.gen.tsx | 9 +- .../src/TestPromise.gen.tsx | 9 +- .../src/Uncurried.gen.tsx | 19 +- .../src/nested/Tuples.gen.tsx | 14 +- .../src/nested/Types.gen.tsx | 14 +- 13 files changed, 23 insertions(+), 315 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index f4306db886..defb6821c1 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -2,7 +2,6 @@ open GenTypeCommon type t = | CircularC of string * t - | FunctionC of functionC | IdentC | OptionC of t | PromiseC of t @@ -12,41 +11,9 @@ and groupedArgConverter = | ArgConverter of t | GroupConverter of (string * optional * t) list -and functionC = { - funArgConverters: groupedArgConverter list; - componentName: string option; - isHook: bool; - retConverter: t; - typeVars: string list; - uncurried: bool; -} - let rec toString converter = match converter with | CircularC (s, c) -> "circular(" ^ s ^ " " ^ toString c ^ ")" - | FunctionC {funArgConverters; retConverter; uncurried} -> - "fn" - ^ (match uncurried with - | true -> "Uncurried" - | false -> "") - ^ "(" - ^ (funArgConverters - |> List.map (fun groupedArgConverter -> - match groupedArgConverter with - | ArgConverter conv -> "(" ^ "_" ^ ":" ^ toString conv ^ ")" - | GroupConverter groupConverters -> - "{|" - ^ (groupConverters - |> List.map (fun (s, optional, argConverter) -> - s - ^ (match optional = Optional with - | true -> "?" - | false -> "") - ^ ":" ^ toString argConverter) - |> String.concat ", ") - ^ "|}") - |> String.concat ", ") - ^ " -> " ^ toString retConverter ^ ")" | IdentC -> "id" | OptionC c -> "option(" ^ toString c ^ ")" | PromiseC c -> "promise(" ^ toString c ^ ")" @@ -63,29 +30,12 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface let _, tNormalized = t |> visit ~visited in (IdentC, Array (tNormalized, mutable_)) | Dict _ -> (IdentC, normalized_) - | Function - ({argTypes; componentName; retType; typeVars; uncurried} as function_) - -> + | Function ({argTypes; retType} as function_) -> let argConverted = argTypes |> List.map (argTypeToGroupedArgConverter ~visited) in - let funArgConverters = argConverted |> List.map fst in - let retConverter, retNormalized = retType |> visit ~visited in - let isHook = - match argTypes with - | [{aType = Object (_, fields)}] -> - retType |> EmitType.isTypeFunctionComponent ~fields - | _ -> false - in - ( FunctionC - { - funArgConverters; - componentName; - isHook; - retConverter; - typeVars; - uncurried; - }, + let _, retNormalized = retType |> visit ~visited in + ( IdentC, Function { function_ with @@ -215,15 +165,6 @@ let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = let rec converterIsIdentity ~config ~toJS converter = match converter with | CircularC (_, c) -> c |> converterIsIdentity ~config ~toJS - | FunctionC {funArgConverters; retConverter; uncurried} -> - retConverter |> converterIsIdentity ~config ~toJS - && ((not toJS) || uncurried || funArgConverters |> List.length <= 1) - && funArgConverters - |> List.for_all (fun groupedArgConverter -> - match groupedArgConverter with - | ArgConverter argConverter -> - argConverter |> converterIsIdentity ~config ~toJS:(not toJS) - | GroupConverter _ -> false) | IdentC -> true | OptionC c -> c |> converterIsIdentity ~config ~toJS | PromiseC c -> c |> converterIsIdentity ~config ~toJS @@ -240,106 +181,6 @@ let rec apply ~(config : Config.t) ~converter ~indent ~nameGen ~toJS ~comment: ("WARNING: circular type " ^ s ^ ". Only shallow converter applied.") |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables - | FunctionC - { - funArgConverters; - componentName; - isHook; - retConverter; - typeVars; - uncurried; - } -> - let resultName = EmitText.resultName ~nameGen in - let indent1 = indent |> Indent.more in - let indent2 = indent1 |> Indent.more in - let mkReturn x = - "const " ^ resultName ^ " = " ^ x ^ ";" - ^ Indent.break ~indent:indent1 - ^ "return " - ^ (resultName - |> apply ~config ~converter:retConverter ~indent:indent2 ~nameGen ~toJS - ~variantTables) - in - let convertArg i groupedArgConverter = - match groupedArgConverter with - | ArgConverter argConverter -> - let varName = i + 1 |> EmitText.argi ~nameGen in - let notToJS = not toJS in - ( [varName], - [ - varName - |> apply ~config ~converter:argConverter ~indent:indent2 ~nameGen - ~toJS:notToJS ~variantTables; - ] ) - | GroupConverter groupConverters -> - let notToJS = not toJS in - if toJS then - let varName = i + 1 |> EmitText.argi ~nameGen in - ( [varName], - groupConverters - |> List.map (fun (label, optional, argConverter) -> - varName - |> EmitText.fieldAccess ~label - |> apply ~config - ~converter: - (match - optional = Optional - && not - (argConverter - |> converterIsIdentity ~config ~toJS:notToJS) - with - | true -> OptionC argConverter - | false -> argConverter) - ~indent:indent2 ~nameGen ~toJS:notToJS ~variantTables) - ) - else - let varNames = - groupConverters - |> List.map (fun (s, _optional, _argConverter) -> - s |> EmitText.arg ~nameGen) - in - let varNamesArr = varNames |> Array.of_list in - let fieldValues = - groupConverters - |> List.mapi (fun i (s, _optional, argConverter) -> - s ^ ":" - ^ ((varNamesArr.(i) [@doesNotRaise]) - |> apply ~config ~converter:argConverter ~indent:indent2 - ~nameGen ~toJS:notToJS ~variantTables)) - |> String.concat ", " - in - (varNames, ["{" ^ fieldValues ^ "}"]) - in - let mkBody bodyArgs = - let useCurry = (not uncurried) && toJS && List.length bodyArgs > 1 in - config.emitImportCurry <- config.emitImportCurry || useCurry; - let functionName = - match isHook with - | true -> "React.createElement" - | false -> value - in - if isHook then config.emitImportReact <- true; - let declareProps, args = - match bodyArgs with - | [props] when isHook -> - let propsName = "$props" |> EmitText.name ~nameGen in - ( Indent.break ~indent:indent1 - ^ "const " ^ propsName ^ " = " ^ props ^ ";", - [value; propsName] ) - | _ -> ("", bodyArgs) - in - declareProps - ^ Indent.break ~indent:indent1 - ^ (functionName |> EmitText.funCall ~args ~useCurry |> mkReturn) - in - let convertedArgs = funArgConverters |> List.mapi convertArg in - let args = convertedArgs |> List.map fst |> List.concat in - let funParams = - args |> List.map (fun v -> v |> EmitType.ofTypeAny ~config) - in - let bodyArgs = convertedArgs |> List.map snd |> List.concat in - EmitText.funDef ~bodyArgs ~functionName:componentName ~funParams ~indent - ~mkBody ~typeVars | IdentC -> value | OptionC c -> EmitText.parens diff --git a/jscomp/gentype/EmitText.ml b/jscomp/gentype/EmitText.ml index 60df74a2bb..46418670fd 100644 --- a/jscomp/gentype/EmitText.ml +++ b/jscomp/gentype/EmitText.ml @@ -10,41 +10,18 @@ let name ~nameGen s = s let parens xs = "(" ^ (xs |> String.concat ", ") ^ ")" -let arg ~nameGen x = "Arg" ^ x |> name ~nameGen -let argi ~nameGen i = "Arg" ^ (i |> string_of_int) |> name ~nameGen -let array xs = "[" ^ (xs |> String.concat ", ") ^ "]" let comment x = "/* " ^ x ^ " */" -let curry ~args ~numArgs name = - match numArgs with - | 0 | 1 -> name ^ parens args - | (2 | 3 | 4 | 5 | 6 | 7 | 8) as n -> - "Curry._" ^ (n |> string_of_int) ^ parens ([name] @ args) - | _ -> "Curry.app" ^ parens [name; args |> array] - -let funCall ~args ~useCurry name = - match useCurry with - | true -> name |> curry ~args ~numArgs:(args |> List.length) - | false -> name ^ parens args let genericsString ~typeVars = match typeVars == [] with | true -> "" | false -> "<" ^ String.concat "," typeVars ^ ">" -let funDef ~bodyArgs ~functionName ~funParams ~indent ~mkBody ~typeVars = - "function " - ^ (match functionName with - | None -> "" - | Some name -> name) - ^ genericsString ~typeVars ^ (funParams |> parens) ^ " {" - ^ (bodyArgs |> mkBody) ^ Indent.break ~indent ^ "}" let newNameGen () = Hashtbl.create 1 let quotes x = "\"" ^ x ^ "\"" -let resultName ~nameGen = "result" |> name ~nameGen - let addComment ~comment x = "\n/* " ^ comment ^ " */\n " ^ x let arrayAccess ~index value = value ^ "[" ^ string_of_int index ^ "]" let fieldAccess ~label value = value ^ "." ^ label diff --git a/jscomp/gentype/GenTypeCommon.ml b/jscomp/gentype/GenTypeCommon.ml index d697bdc033..a77371c4c3 100644 --- a/jscomp/gentype/GenTypeCommon.ml +++ b/jscomp/gentype/GenTypeCommon.ml @@ -97,22 +97,6 @@ and variant = { and payload = {case: case; inlineRecord: bool; numArgs: int; t: type_} -let typeIsObject type_ = - match type_ with - | Array _ -> true - | Dict _ -> true - | Function _ -> false - | GroupOfLabeledArgs _ -> false - | Ident _ -> false - | Null _ -> false - | Nullable _ -> false - | Object _ -> true - | Option _ -> false - | Promise _ -> true - | Tuple _ -> true - | TypeVar _ -> false - | Variant _ -> false - type label = Nolabel | Label of string | OptLabel of string type dep = diff --git a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx index 83633212d1..2e6ff2cb51 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Docstrings.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as DocstringsBS__Es6Import from './Docstrings.bs'; const DocstringsBS: any = DocstringsBS__Es6Import; @@ -21,15 +17,9 @@ export const signMessage: (message:string, key:number) => string = DocstringsBS. export const one: (a:number) => number = DocstringsBS.one; -export const two: (a:number, b:number) => number = function (Arg1: any, Arg2: any) { - const result = Curry._2(DocstringsBS.two, Arg1, Arg2); - return result -}; +export const two: (a:number, b:number) => number = DocstringsBS.two; -export const tree: (a:number, b:number, c:number) => number = function (Arg1: any, Arg2: any, Arg3: any) { - const result = Curry._3(DocstringsBS.tree, Arg1, Arg2, Arg3); - return result -}; +export const tree: (a:number, b:number, c:number) => number = DocstringsBS.tree; export const oneU: (a:number) => number = DocstringsBS.oneU; @@ -45,17 +35,11 @@ export const unnamed1: (param:number) => number = DocstringsBS.unnamed1; export const unnamed1U: (param:number) => number = DocstringsBS.unnamed1U; -export const unnamed2: (param_0:number, param_1:number) => number = function (Arg1: any, Arg2: any) { - const result = Curry._2(DocstringsBS.unnamed2, Arg1, Arg2); - return result -}; +export const unnamed2: (param_0:number, param_1:number) => number = DocstringsBS.unnamed2; export const unnamed2U: (param_0:number, param_1:number) => number = DocstringsBS.unnamed2U; -export const grouped: (_1:{ readonly x: number; readonly y: number }, a:number, b:number, c:number, _5:{ readonly z: number }) => number = function (Arg1: any, Arg2: any, Arg3: any, Arg4: any, Arg5: any) { - const result = Curry._6(DocstringsBS.grouped, Arg1.x, Arg1.y, Arg2, Arg3, Arg4, Arg5.z); - return result -}; +export const grouped: (_1:{ readonly x: number; readonly y: number }, a:number, b:number, c:number, _5:{ readonly z: number }) => number = DocstringsBS.grouped; export const unitArgWithoutConversion: () => string = DocstringsBS.unitArgWithoutConversion; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx index 29db86f649..f4c0651a29 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.gen.tsx @@ -4,10 +4,6 @@ import * as React from 'react'; -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as HooksBS__Es6Import from './Hooks.bs'; const HooksBS: any = HooksBS__Es6Import; @@ -79,13 +75,7 @@ export const functionWithRenamedArgs: (_1:{ readonly to: vehicle; readonly Type: vehicle; readonly cb: cb -}) => string = function (Arg1: any) { - const result = Curry._3(HooksBS.functionWithRenamedArgs, Arg1.to, Arg1.Type, function (Argto: any) { - const result1 = Arg1.cb({to:Argto}); - return result1 - }); - return result -}; +}) => string = HooksBS.functionWithRenamedArgs; // tslint:disable-next-line:interface-over-type-literal export type WithRename_componentWithRenamedArgs_Props = { @@ -100,10 +90,7 @@ export const WithRename_componentWithRenamedArgs: React.ComponentType<{ readonly cb: cb }> = HooksBS.WithRename.componentWithRenamedArgs; -export const WithRef_makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element = function (Arg1: any, Arg2: any) { - const result = Curry._2(HooksBS.WithRef.makeWithRef, Arg1, Arg2); - return result -}; +export const WithRef_makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element = HooksBS.WithRef.makeWithRef; // tslint:disable-next-line:interface-over-type-literal export type testForwardRef_Props = { readonly vehicle: vehicle }; @@ -175,6 +162,8 @@ export const ForwardRef: { input: React.ComponentType<{ readonly r: r }> } = Hoo export const Fun: { functionReturningReactElement: React.ComponentType<{ readonly name: string }> } = HooksBS.Fun +export const WithRef: { makeWithRef: (_1:{ readonly vehicle: vehicle }, _2:(null | undefined | any)) => JSX.Element } = HooksBS.WithRef + export const WithChildren: { aComponentWithChildren: React.ComponentType<{ readonly children: React.ReactNode; readonly vehicle: vehicle }> } = HooksBS.WithChildren export const DD: { make: React.ComponentType<{ readonly array: Js_TypedArray2_Uint8Array_t; readonly name: string }> } = HooksBS.DD diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportHooks.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ImportHooks.gen.tsx index 0ffc03894d..e0874a2b7d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportHooks.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportHooks.gen.tsx @@ -26,10 +26,7 @@ export const makeRenamed: unknown = makeRenamedTypeChecked as React.ComponentTyp export const fooTypeChecked: (_1:{ readonly person: person }) => string = fooNotChecked; // Export 'foo' early to allow circular import from the '.bs.js' file. -export const foo: unknown = function (Argperson: any) { - const result = fooTypeChecked({person:Argperson}); - return result -} as (_1:{ readonly person: person }) => string; +export const foo: unknown = fooTypeChecked as (_1:{ readonly person: person }) => string; // tslint:disable-next-line:interface-over-type-literal export type person = { readonly name: string; readonly age: number }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx index 7630e3a4df..ea763fd2b5 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.gen.tsx @@ -20,10 +20,6 @@ import {polymorphic as polymorphicNotChecked} from './MyMath'; import {default as defaultNotChecked} from './MyMath'; -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // In case of type error, check the type of 'round' in 'ImportJsValue.res' and './MyMath'. export const roundTypeChecked: (_1:number) => number = roundNotChecked; @@ -58,13 +54,7 @@ export const useColor: unknown = useColorTypeChecked as (_1:color) => number; export const higherOrderTypeChecked: (_1:((_1:number, _2:number) => number)) => number = higherOrderNotChecked; // Export 'higherOrder' early to allow circular import from the '.bs.js' file. -export const higherOrder: unknown = function (Arg1: any) { - const result = higherOrderTypeChecked(function (Arg11: any, Arg2: any) { - const result1 = Curry._2(Arg1, Arg11, Arg2); - return result1 - }); - return result -} as (_1:((_1:number, _2:number) => number)) => number; +export const higherOrder: unknown = higherOrderTypeChecked as (_1:((_1:number, _2:number) => number)) => number; // In case of type error, check the type of 'convertVariant' in 'ImportJsValue.res' and './MyMath'. export const convertVariantTypeChecked: (_1:variant) => variant = convertVariantNotChecked; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx index 8f55429085..ef6d6b7615 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as RecordsBS__Es6Import from './Records.bs'; const RecordsBS: any = RecordsBS__Es6Import; @@ -76,10 +72,7 @@ export const origin: coord = RecordsBS.origin; export const computeArea: (param:coord) => number = RecordsBS.computeArea; -export const coord2d: (x:number, y:number) => coord = function (Arg1: any, Arg2: any) { - const result = Curry._2(RecordsBS.coord2d, Arg1, Arg2); - return result -}; +export const coord2d: (x:number, y:number) => coord = RecordsBS.coord2d; export const findAddress: (business:business) => list = RecordsBS.findAddress; diff --git a/jscomp/gentype_tests/typescript-react-example/src/References.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/References.gen.tsx index fec3a03b43..ee18c0af0f 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/References.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/References.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as ReferencesBS__Es6Import from './References.bs'; const ReferencesBS: any = ReferencesBS__Es6Import; @@ -29,10 +25,7 @@ export const get: (_1:R_t) => T1 = ReferencesBS.get; export const make: (_1:T1) => R_t = ReferencesBS.make; -export const set: (_1:R_t, _2:T1) => void = function (Arg1: any, Arg2: any) { - const result = Curry._2(ReferencesBS.set, Arg1, Arg2); - return result -}; +export const set: (_1:R_t, _2:T1) => void = ReferencesBS.set; export const destroysRefIdentity: (x:{ contents: requiresConversion }) => { contents: requiresConversion } = ReferencesBS.destroysRefIdentity; diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx index fb57d54ad6..2b8f97eadb 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as TestPromiseBS__Es6Import from './TestPromise.bs'; const TestPromiseBS: any = TestPromiseBS__Es6Import; @@ -21,7 +17,4 @@ export type toPayload = { readonly result: string }; export const convert: (_1:Promise) => Promise = TestPromiseBS.convert; -export const barx: (_1:{ readonly x?: Promise<(undefined | string)> }, _2:void) => boolean = function (Arg1: any, Arg2: any) { - const result = Curry._2(TestPromiseBS.barx, Arg1.x, Arg2); - return result -}; +export const barx: (_1:{ readonly x?: Promise<(undefined | string)> }, _2:void) => boolean = TestPromiseBS.barx; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx index 27fe26be62..1fa912985f 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as UncurriedBS__Es6Import from './Uncurried.bs'; const UncurriedBS: any = UncurriedBS__Es6Import; @@ -36,10 +32,7 @@ export const uncurried2: (x:number, y:string) => string = UncurriedBS.uncurried2 export const uncurried3: (x:number, y:string, z:number) => string = UncurriedBS.uncurried3; -export const curried3: (x:number, y:string, z:number) => string = function (Arg1: any, Arg2: any, Arg3: any) { - const result = Curry._3(UncurriedBS.curried3, Arg1, Arg2, Arg3); - return result -}; +export const curried3: (x:number, y:string, z:number) => string = UncurriedBS.curried3; export const callback: (cb:(() => number)) => string = UncurriedBS.callback; @@ -51,12 +44,6 @@ export const sumU: (n:number, m:number) => void = UncurriedBS.sumU; export const sumU2: (n:number) => (_1:number) => void = UncurriedBS.sumU2; -export const sumCurried: (n:number, _2:number) => void = function (Arg1: any, Arg2: any) { - const result = Curry._2(UncurriedBS.sumCurried, Arg1, Arg2); - return result -}; +export const sumCurried: (n:number, _2:number) => void = UncurriedBS.sumCurried; -export const sumLblCurried: (s:string, _2:{ readonly n: number; readonly m: number }) => void = function (Arg1: any, Arg2: any) { - const result = Curry._3(UncurriedBS.sumLblCurried, Arg1, Arg2.n, Arg2.m); - return result -}; +export const sumLblCurried: (s:string, _2:{ readonly n: number; readonly m: number }) => void = UncurriedBS.sumLblCurried; diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.gen.tsx index 67223c651e..1419d29251 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as TuplesBS__Es6Import from './Tuples.bs'; const TuplesBS: any = TuplesBS__Es6Import; @@ -32,16 +28,10 @@ export const computeAreaWithIdent: (param:coord) => number = TuplesBS.computeAre export const computeAreaNoConverters: (param:[number, number]) => number = TuplesBS.computeAreaNoConverters; -export const coord2d: (x:T1, y:T2) => [T1, T2, (undefined | T3)] = function (Arg1: any, Arg2: any) { - const result = Curry._2(TuplesBS.coord2d, Arg1, Arg2); - return result -}; +export const coord2d: (x:T1, y:T2) => [T1, T2, (undefined | T3)] = TuplesBS.coord2d; export const getFirstName: (param:couple) => string = TuplesBS.getFirstName; -export const marry: (first:person, second:person) => couple = function (Arg1: any, Arg2: any) { - const result = Curry._2(TuplesBS.marry, Arg1, Arg2); - return result -}; +export const marry: (first:person, second:person) => couple = TuplesBS.marry; export const changeSecondAge: (param:couple) => couple = TuplesBS.changeSecondAge; diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx index 3549157d62..3d4974ee56 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx @@ -2,10 +2,6 @@ /* eslint-disable import/first */ -// @ts-ignore: Implicit any on import -import * as Curry__Es6Import from 'rescript/lib/es6/curry.js'; -const Curry: any = Curry__Es6Import; - // @ts-ignore: Implicit any on import import * as TypesBS__Es6Import from './Types.bs'; const TypesBS: any = TypesBS__Es6Import; @@ -115,10 +111,7 @@ export type tPrimed = [TypeNameSanitize_t_, TypeNameSanitize_M_t__]; export const someIntList: list = TypesBS.someIntList; -export const map: (_1:((_1:T1) => T2), _2:list) => list = function (Arg1: any, Arg2: any) { - const result = Curry._2(TypesBS.map, Arg1, Arg2); - return result -}; +export const map: (_1:((_1:T1) => T2), _2:list) => list = TypesBS.map; export const swap: (tree:tree) => tree = TypesBS.swap; @@ -126,10 +119,7 @@ export const selfRecursiveConverter: (param:selfRecursive) => selfRecursive = Ty export const mutuallyRecursiveConverter: (param:mutuallyRecursiveA) => mutuallyRecursiveB = TypesBS.mutuallyRecursiveConverter; -export const testFunctionOnOptionsAsArgument: (a:(undefined | a), foo:((_1:(undefined | a)) => T1)) => T1 = function (Arg1: any, Arg2: any) { - const result = Curry._2(TypesBS.testFunctionOnOptionsAsArgument, Arg1, Arg2); - return result -}; +export const testFunctionOnOptionsAsArgument: (a:(undefined | a), foo:((_1:(undefined | a)) => T1)) => T1 = TypesBS.testFunctionOnOptionsAsArgument; export const stringT: string = TypesBS.stringT; From 61a6211e838e58e50058939bf01a04bd5797350c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:14:58 +0200 Subject: [PATCH 15/20] Allow recursive types. Fixes https://github.com/rescript-association/genType/issues/585 --- CHANGELOG.md | 1 + jscomp/gentype/Converter.ml | 25 +++---------------- .../src/Variants.gen.tsx | 8 ++++++ .../typescript-react-example/src/Variants.res | 6 +++++ 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef6137b65b..346df05115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ These are only breaking changes for unformatted code. - Change the compilation of pattern matching for variants so it does not depends on variats being integers https://github.com/rescript-lang/rescript-compiler/pull/6085 - Improve code generated for string templates https://github.com/rescript-lang/rescript-compiler/pull/6090 - Move Jsx and JsxDOM and JsxEvent and JsxPPXReactSupport inside Pervasives and build them separately for curried and uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/6091 +- Gentype: allow recursive data types https://github.com/rescript-association/genType/issues/585 # 10.1.4 diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index defb6821c1..7e7b2038f0 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,11 +1,6 @@ open GenTypeCommon -type t = - | CircularC of string * t - | IdentC - | OptionC of t - | PromiseC of t - | TupleC of t list +type t = IdentC | OptionC of t | PromiseC of t | TupleC of t list and groupedArgConverter = | ArgConverter of t @@ -13,7 +8,6 @@ and groupedArgConverter = let rec toString converter = match converter with - | CircularC (s, c) -> "circular(" ^ s ^ " " ^ toString c ^ ")" | IdentC -> "id" | OptionC c -> "option(" ^ toString c ^ ")" | PromiseC c -> "promise(" ^ toString c ^ ")" @@ -51,6 +45,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface circular := name; (IdentC, normalized_)) else + let visited = visited |> StringSet.add name in match name |> lookupId with | {CodeItem.annotation = GenTypeOpaque} -> (IdentC, normalized_) | {annotation = NoGenType} -> (IdentC, normalized_) @@ -140,16 +135,11 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface (converter, {aName; aType = tNormalized}) in let converter, normalized = type0 |> visit ~visited:StringSet.empty in - let finalConverter = - match !circular <> "" with - | true -> CircularC (!circular, converter) - | false -> converter - in if !Debug.converter then Log_.item "Converter type0:%s converter:%s\n" (type0 |> EmitType.typeToString ~config ~typeNameIsInterface) - (finalConverter |> toString); - (finalConverter, normalized) + (converter |> toString); + (converter, normalized) let typeGetConverter ~config ~lookupId ~typeNameIsInterface type_ = type_ @@ -164,7 +154,6 @@ let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = let rec converterIsIdentity ~config ~toJS converter = match converter with - | CircularC (_, c) -> c |> converterIsIdentity ~config ~toJS | IdentC -> true | OptionC c -> c |> converterIsIdentity ~config ~toJS | PromiseC c -> c |> converterIsIdentity ~config ~toJS @@ -175,12 +164,6 @@ let rec apply ~(config : Config.t) ~converter ~indent ~nameGen ~toJS ~variantTables value = match converter with | _ when converter |> converterIsIdentity ~config ~toJS -> value - | CircularC (s, c) -> - value - |> EmitText.addComment - ~comment: - ("WARNING: circular type " ^ s ^ ". Only shallow converter applied.") - |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables | IdentC -> value | OptionC c -> EmitText.parens diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx index c5d5f0b5b5..da51badee7 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.gen.tsx @@ -6,6 +6,8 @@ import * as VariantsBS__Es6Import from './Variants.bs'; const VariantsBS: any = VariantsBS__Es6Import; +import type {list} from '../src/shims/RescriptPervasives.shim'; + // tslint:disable-next-line:interface-over-type-literal export type weekday = "monday" @@ -35,6 +37,12 @@ export type x2 = "x" | "same"; export type type_ = "type"; export type type = type_; +// tslint:disable-next-line:interface-over-type-literal +export type myList = "E" | { TAG: "C"; _0: number; _1: myList }; + +// tslint:disable-next-line:interface-over-type-literal +export type builtinList = list; + // tslint:disable-next-line:interface-over-type-literal export type result1 = { TAG: "Ok"; _0: a } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Variants.res b/jscomp/gentype_tests/typescript-react-example/src/Variants.res index 9dcb2a491b..4dcde43f9f 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Variants.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Variants.res @@ -79,6 +79,12 @@ type testGenTypeAs3 = [ @genType @genType.as("type") type type_ = | @genType.as("type") Type +@genType +type rec myList = E | C(int, myList) + +@genType +type builtinList = list + @genType let polyWithOpt = foo => foo === "bar" From 63e39fa0f95c106ad767a324e06f8f26cd757cf3 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:18:40 +0200 Subject: [PATCH 16/20] Remove option converter. --- jscomp/gentype/Converter.ml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 7e7b2038f0..a73569be4e 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,6 +1,6 @@ open GenTypeCommon -type t = IdentC | OptionC of t | PromiseC of t | TupleC of t list +type t = IdentC | PromiseC of t | TupleC of t list and groupedArgConverter = | ArgConverter of t @@ -9,7 +9,6 @@ and groupedArgConverter = let rec toString converter = match converter with | IdentC -> "id" - | OptionC c -> "option(" ^ toString c ^ ")" | PromiseC c -> "promise(" ^ toString c ^ ")" | TupleC innerTypesC -> "[" ^ (innerTypesC |> List.map toString |> String.concat ", ") ^ "]" @@ -75,15 +74,15 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface (IdentC, Ident {builtin = false; name; typeArgs}) else (IdentC, normalized_)) | Null t -> - let tConverter, tNormalized = t |> visit ~visited in - (OptionC tConverter, Null tNormalized) + let _, tNormalized = t |> visit ~visited in + (IdentC, Null tNormalized) | Nullable t -> - let tConverter, tNormalized = t |> visit ~visited in - (OptionC tConverter, Nullable tNormalized) + let _, tNormalized = t |> visit ~visited in + (IdentC, Nullable tNormalized) | Object _ -> (IdentC, normalized_) | Option t -> - let tConverter, tNormalized = t |> visit ~visited in - (OptionC tConverter, Option tNormalized) + let _, tNormalized = t |> visit ~visited in + (IdentC, Option tNormalized) | Promise t -> let tConverter, tNormalized = t |> visit ~visited in (PromiseC tConverter, Promise tNormalized) @@ -155,7 +154,6 @@ let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = let rec converterIsIdentity ~config ~toJS converter = match converter with | IdentC -> true - | OptionC c -> c |> converterIsIdentity ~config ~toJS | PromiseC c -> c |> converterIsIdentity ~config ~toJS | TupleC innerTypesC -> innerTypesC |> List.for_all (converterIsIdentity ~config ~toJS) @@ -165,13 +163,6 @@ let rec apply ~(config : Config.t) ~converter ~indent ~nameGen ~toJS match converter with | _ when converter |> converterIsIdentity ~config ~toJS -> value | IdentC -> value - | OptionC c -> - EmitText.parens - [ - value ^ " == null ? " ^ value ^ " : " - ^ (value - |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables); - ] | PromiseC c -> let x = "$promise" |> EmitText.name ~nameGen in value ^ ".then(function _element(" From 48aea0df0079385dcae8d4fdfa47adb18e1b0599 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:28:19 +0200 Subject: [PATCH 17/20] Remove some conversion code. --- jscomp/gentype/Converter.ml | 50 ++++------------------------------ jscomp/gentype/EmitJs.ml | 19 ++++--------- jscomp/gentype/ExportModule.ml | 35 +++++------------------- 3 files changed, 19 insertions(+), 85 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index a73569be4e..21737e3872 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,17 +1,14 @@ open GenTypeCommon -type t = IdentC | PromiseC of t | TupleC of t list +type t = IdentC and groupedArgConverter = | ArgConverter of t | GroupConverter of (string * optional * t) list -let rec toString converter = +let toString converter = match converter with | IdentC -> "id" - | PromiseC c -> "promise(" ^ toString c ^ ")" - | TupleC innerTypesC -> - "[" ^ (innerTypesC |> List.map toString |> String.concat ", ") ^ "]" let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface type0 = @@ -84,13 +81,13 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface let _, tNormalized = t |> visit ~visited in (IdentC, Option tNormalized) | Promise t -> - let tConverter, tNormalized = t |> visit ~visited in - (PromiseC tConverter, Promise tNormalized) + let _, tNormalized = t |> visit ~visited in + (IdentC, Promise tNormalized) | Tuple innerTypes -> - let innerConversions, normalizedList = + let _, normalizedList = innerTypes |> List.map (visit ~visited) |> List.split in - (TupleC innerConversions, Tuple normalizedList) + (IdentC, Tuple normalizedList) | TypeVar _ -> (IdentC, normalized_) | Variant variant -> let ordinaryVariant = not variant.polymorphic in @@ -150,38 +147,3 @@ let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = type_ |> typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface |> snd - -let rec converterIsIdentity ~config ~toJS converter = - match converter with - | IdentC -> true - | PromiseC c -> c |> converterIsIdentity ~config ~toJS - | TupleC innerTypesC -> - innerTypesC |> List.for_all (converterIsIdentity ~config ~toJS) - -let rec apply ~(config : Config.t) ~converter ~indent ~nameGen ~toJS - ~variantTables value = - match converter with - | _ when converter |> converterIsIdentity ~config ~toJS -> value - | IdentC -> value - | PromiseC c -> - let x = "$promise" |> EmitText.name ~nameGen in - value ^ ".then(function _element(" - ^ (x |> EmitType.ofTypeAny ~config) - ^ ") { return " - ^ (x |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables) - ^ "})" - | TupleC innerTypesC -> - "[" - ^ (innerTypesC - |> List.mapi (fun index c -> - value - |> EmitText.arrayAccess ~index - |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables) - |> String.concat ", ") - ^ "]" - -let toJS ~config ~converter ~indent ~nameGen ~variantTables value = - value |> apply ~config ~converter ~indent ~nameGen ~variantTables ~toJS:true - -let toReason ~config ~converter ~indent ~nameGen ~variantTables value = - value |> apply ~config ~converter ~indent ~nameGen ~toJS:false ~variantTables diff --git a/jscomp/gentype/EmitJs.ml b/jscomp/gentype/EmitJs.ml index 06b5a4d864..8bd6034d55 100644 --- a/jscomp/gentype/EmitJs.ml +++ b/jscomp/gentype/EmitJs.ml @@ -130,14 +130,12 @@ let emitExportFromTypeDeclarations ~config ~emitters ~env ~typeGetNormalized let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName ~outputFileRelative ~resolver ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized ~typeNameIsInterface ~variantTables codeItem = + ~typeGetNormalized ~typeNameIsInterface codeItem = if !Debug.codeItems then Log_.item "Code Item: %s\n" (codeItem |> codeItemToString ~config ~typeNameIsInterface); - let indent = Some "" in match codeItem with | ImportValue {asPath; importAnnotation; type_; valueName} -> - let nameGen = EmitText.newNameGen () in let importPath = importAnnotation.importPath in let importFile = importAnnotation.name in let firstNameInPath, restOfPath = @@ -220,7 +218,6 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName | _ -> type_) | _ -> type_ in - let converter = type_ |> typeGetConverter in let valueNameTypeChecked = valueName ^ "TypeChecked" in let emitters = (importedAsName ^ restOfPath) ^ ";" @@ -242,7 +239,6 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName in let emitters = (valueNameTypeChecked - |> Converter.toReason ~config ~converter ~indent ~nameGen ~variantTables |> EmitType.emitTypeCast ~config ~type_ ~typeNameIsInterface) ^ ";" |> EmitType.emitExportConst @@ -261,7 +257,6 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName | ExportValue {docString; moduleAccessPath; originalName; resolvedName; type_} -> let resolvedNameStr = ResolvedName.toString resolvedName in - let nameGen = EmitText.newNameGen () in let importPath = fileName |> ModuleResolver.resolveModule ~config ~importExtension:config.suffix @@ -400,9 +395,8 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName in let emitters = ((fileNameBs |> ModuleName.toString) - ^ "." - ^ (moduleAccessPath |> Runtime.emitModuleAccessPath ~config) - |> Converter.toJS ~config ~converter ~indent ~nameGen ~variantTables) + ^ "." + ^ (moduleAccessPath |> Runtime.emitModuleAccessPath ~config)) ^ ";" |> EmitType.emitExportConst ~config ~docString ~early:false ~emitters ~name ~type_ ~typeNameIsInterface @@ -416,13 +410,13 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName let emitCodeItems ~config ~outputFileRelative ~emitters ~moduleItemsEmitter ~env ~fileName ~resolver ~typeNameIsInterface ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized ~variantTables codeItems = + ~typeGetNormalized codeItems = codeItems |> List.fold_left (fun (env, emitters) -> emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName ~outputFileRelative ~resolver ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized ~typeNameIsInterface ~variantTables) + ~typeGetNormalized ~typeNameIsInterface) (env, emitters) let emitRequires ~importedValueOrComponent ~early ~config ~requires emitters = @@ -630,7 +624,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations importedValueOrComponent = false; } in - let variantTables = Hashtbl.create 1 in let exportTypeMap, annotatedSet = translation.typeDeclarations |> createExportTypeMap ~config @@ -712,7 +705,7 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized:(typeGetNormalized_ ~env) ~typeGetConverter:(typeGetConverter_ ~env) - ~typeNameIsInterface:(typeNameIsInterface ~env) ~variantTables + ~typeNameIsInterface:(typeNameIsInterface ~env) in let emitters = match config.emitImportReact with diff --git a/jscomp/gentype/ExportModule.ml b/jscomp/gentype/ExportModule.ml index e41ac52703..a61c132c4a 100644 --- a/jscomp/gentype/ExportModule.ml +++ b/jscomp/gentype/ExportModule.ml @@ -8,23 +8,13 @@ and exportModuleValue = type exportModuleItems = (string, exportModuleItem) Hashtbl.t -type types = {typeForValue: type_; typeForType: type_; needsConversion: bool} +type types = {typeForValue: type_; typeForType: type_} -type fieldInfo = { - fieldForValue: field; - fieldForType: field; - needsConversion: bool; -} +type fieldInfo = {fieldForValue: field; fieldForType: field} let rec exportModuleValueToType ~config exportModuleValue = match exportModuleValue with - | S (s, type_, converter) -> - { - typeForValue = ident s; - typeForType = type_; - needsConversion = - not (converter |> Converter.converterIsIdentity ~config ~toJS:true); - } + | S (s, type_, _converter) -> {typeForValue = ident s; typeForType = type_} | M exportModuleItem -> let fieldsInfo = exportModuleItem |> exportModuleItemToFields ~config in let fieldsForValue = @@ -33,23 +23,16 @@ let rec exportModuleValueToType ~config exportModuleValue = let fieldsForType = fieldsInfo |> List.map (fun {fieldForType} -> fieldForType) in - let needsConversion = - fieldsInfo - |> List.fold_left - (fun acc {needsConversion} -> acc || needsConversion) - false - in { typeForValue = Object (Open, fieldsForValue); typeForType = Object (Open, fieldsForType); - needsConversion; } and exportModuleItemToFields = (fun ~config exportModuleItem -> Hashtbl.fold (fun fieldName exportModuleValue fields -> - let {typeForValue; typeForType; needsConversion} = + let {typeForValue; typeForType} = exportModuleValue |> exportModuleValueToType ~config in let fieldForType = @@ -61,7 +44,7 @@ and exportModuleItemToFields = } in let fieldForValue = {fieldForType with type_ = typeForValue} in - {fieldForValue; fieldForType; needsConversion} :: fields) + {fieldForValue; fieldForType} :: fields) exportModuleItem [] : config:Config.t -> exportModuleItem -> fieldInfo list) @@ -114,14 +97,10 @@ let emitAllModuleItems ~config ~emitters ~fileName emitters |> rev_fold (fun moduleName exportModuleItem emitters -> - let {typeForType; needsConversion} = + let {typeForType} = M exportModuleItem |> exportModuleValueToType ~config in - if !Debug.codeItems then - Log_.item "EmitModule %s needsConversion:%b@." moduleName - needsConversion; - if needsConversion then emitters - else + if !Debug.codeItems then Log_.item "EmitModule %s @." moduleName; let emittedModuleItem = ModuleName.forInnerModule ~fileName ~innerModuleName:moduleName |> ModuleName.toString From 780ca1d6913dee29af24a8d6863a7f244fa8cfcf Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:38:17 +0200 Subject: [PATCH 18/20] Remove conversion code. --- jscomp/gentype/Converter.ml | 114 +++++++++++---------------------- jscomp/gentype/EmitJs.ml | 22 ++----- jscomp/gentype/ExportModule.ml | 46 ++++++------- 3 files changed, 67 insertions(+), 115 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index 21737e3872..f8b3c708c6 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,15 +1,5 @@ open GenTypeCommon -type t = IdentC - -and groupedArgConverter = - | ArgConverter of t - | GroupConverter of (string * optional * t) list - -let toString converter = - match converter with - | IdentC -> "id" - let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface type0 = let circular = ref "" in @@ -17,34 +7,28 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface let normalized_ = type_ in match type_ with | Array (t, mutable_) -> - let _, tNormalized = t |> visit ~visited in - (IdentC, Array (tNormalized, mutable_)) - | Dict _ -> (IdentC, normalized_) + let tNormalized = t |> visit ~visited in + Array (tNormalized, mutable_) + | Dict _ -> normalized_ | Function ({argTypes; retType} as function_) -> let argConverted = argTypes |> List.map (argTypeToGroupedArgConverter ~visited) in - let _, retNormalized = retType |> visit ~visited in - ( IdentC, - Function - { - function_ with - argTypes = argConverted |> List.map snd; - retType = retNormalized; - } ) + let retNormalized = retType |> visit ~visited in + Function {function_ with argTypes = argConverted; retType = retNormalized} | GroupOfLabeledArgs _ -> (* This case should only fire from withing a function *) - (IdentC, normalized_) - | Ident {builtin = true} -> (IdentC, normalized_) + normalized_ + | Ident {builtin = true} -> normalized_ | Ident {builtin = false; name; typeArgs} -> ( if visited |> StringSet.mem name then ( circular := name; - (IdentC, normalized_)) + normalized_) else let visited = visited |> StringSet.add name in match name |> lookupId with - | {CodeItem.annotation = GenTypeOpaque} -> (IdentC, normalized_) - | {annotation = NoGenType} -> (IdentC, normalized_) + | {CodeItem.annotation = GenTypeOpaque} -> normalized_ + | {annotation = NoGenType} -> normalized_ | {typeVars; type_} -> ( let pairs = try List.combine typeVars typeArgs with Invalid_argument _ -> [] @@ -56,45 +40,40 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface | _, typeArgument -> Some typeArgument | exception Not_found -> None in - let converter, inlined = - type_ |> TypeVars.substitute ~f |> visit ~visited - in - ( converter, - match inline with - | true -> inlined - | false -> normalized_ )) + let inlined = type_ |> TypeVars.substitute ~f |> visit ~visited in + match inline with + | true -> inlined + | false -> normalized_) | exception Not_found -> if inline then let typeArgs = - typeArgs |> List.map (fun t -> t |> visit ~visited |> snd) + typeArgs |> List.map (fun t -> t |> visit ~visited) in - (IdentC, Ident {builtin = false; name; typeArgs}) - else (IdentC, normalized_)) + Ident {builtin = false; name; typeArgs} + else normalized_) | Null t -> - let _, tNormalized = t |> visit ~visited in - (IdentC, Null tNormalized) + let tNormalized = t |> visit ~visited in + Null tNormalized | Nullable t -> - let _, tNormalized = t |> visit ~visited in - (IdentC, Nullable tNormalized) - | Object _ -> (IdentC, normalized_) + let tNormalized = t |> visit ~visited in + Nullable tNormalized + | Object _ -> normalized_ | Option t -> - let _, tNormalized = t |> visit ~visited in - (IdentC, Option tNormalized) + let tNormalized = t |> visit ~visited in + Option tNormalized | Promise t -> - let _, tNormalized = t |> visit ~visited in - (IdentC, Promise tNormalized) + let tNormalized = t |> visit ~visited in + Promise tNormalized | Tuple innerTypes -> - let _, normalizedList = - innerTypes |> List.map (visit ~visited) |> List.split - in - (IdentC, Tuple normalizedList) - | TypeVar _ -> (IdentC, normalized_) + let normalizedList = innerTypes |> List.map (visit ~visited) in + Tuple normalizedList + | TypeVar _ -> normalized_ | Variant variant -> let ordinaryVariant = not variant.polymorphic in let withPayloadConverted = variant.payloads |> List.map (fun (payload : payload) -> - {payload with t = snd (payload.t |> visit ~visited)}) + {payload with t = payload.t |> visit ~visited}) in let normalized = match withPayloadConverted with @@ -105,7 +84,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface | withPayloadConverted -> Variant {variant with payloads = withPayloadConverted} in - (IdentC, normalized) + normalized and argTypeToGroupedArgConverter ~visited {aName; aType} = match aType with | GroupOfLabeledArgs fields -> @@ -116,34 +95,19 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface let tNormalized = GroupOfLabeledArgs (fieldsConverted - |> List.map (fun (field, (_, t)) -> {field with type_ = t})) + |> List.map (fun (field, t) -> {field with type_ = t})) in - let converter = - GroupConverter - (fieldsConverted - |> List.map (fun ({nameJS; optional}, (converter, _)) -> - (nameJS, optional, converter))) - in - (converter, {aName; aType = tNormalized}) + {aName; aType = tNormalized} | _ -> - let converter, tNormalized = aType |> visit ~visited in - let converter = ArgConverter converter in - (converter, {aName; aType = tNormalized}) + let tNormalized = aType |> visit ~visited in + {aName; aType = tNormalized} in - let converter, normalized = type0 |> visit ~visited:StringSet.empty in + let normalized = type0 |> visit ~visited:StringSet.empty in if !Debug.converter then - Log_.item "Converter type0:%s converter:%s\n" - (type0 |> EmitType.typeToString ~config ~typeNameIsInterface) - (converter |> toString); - (converter, normalized) - -let typeGetConverter ~config ~lookupId ~typeNameIsInterface type_ = - type_ - |> typeGetConverterNormalized ~config ~inline:false ~lookupId - ~typeNameIsInterface - |> fst + Log_.item "type0:%s \n" + (type0 |> EmitType.typeToString ~config ~typeNameIsInterface); + normalized let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = type_ |> typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface - |> snd diff --git a/jscomp/gentype/EmitJs.ml b/jscomp/gentype/EmitJs.ml index 8bd6034d55..3caedf3952 100644 --- a/jscomp/gentype/EmitJs.ml +++ b/jscomp/gentype/EmitJs.ml @@ -129,8 +129,8 @@ let emitExportFromTypeDeclarations ~config ~emitters ~env ~typeGetNormalized (env, emitters) let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName - ~outputFileRelative ~resolver ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized ~typeNameIsInterface codeItem = + ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized + ~typeNameIsInterface codeItem = if !Debug.codeItems then Log_.item "Code Item: %s\n" (codeItem |> codeItemToString ~config ~typeNameIsInterface); @@ -370,9 +370,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName | _ -> (type_, None) in - let converter = type_ |> typeGetConverter in - resolvedName - |> ExportModule.extendExportModules ~converter ~moduleItemsEmitter ~type_; + resolvedName |> ExportModule.extendExportModules ~moduleItemsEmitter ~type_; let emitters = match hookType with | Some {propsType; resolvedTypeName; typeVars} -> @@ -409,14 +407,14 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName (envWithRequires, emitters) let emitCodeItems ~config ~outputFileRelative ~emitters ~moduleItemsEmitter ~env - ~fileName ~resolver ~typeNameIsInterface ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized codeItems = + ~fileName ~resolver ~typeNameIsInterface ~inlineOneLevel ~typeGetNormalized + codeItems = codeItems |> List.fold_left (fun (env, emitters) -> emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName - ~outputFileRelative ~resolver ~typeGetConverter ~inlineOneLevel - ~typeGetNormalized ~typeNameIsInterface) + ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized + ~typeNameIsInterface) (env, emitters) let emitRequires ~importedValueOrComponent ~early ~config ~requires emitters = @@ -659,11 +657,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations ~typeNameIsInterface:(typeNameIsInterface ~env) in let typeGetNormalized_ = typeGetNormalized__ ~inline:false in - let typeGetConverter_ ~env type_ = - type_ - |> Converter.typeGetConverter ~config ~lookupId:(lookupId_ ~env) - ~typeNameIsInterface:(typeNameIsInterface ~env) - in let emitters = Emitters.initial and moduleItemsEmitter = ExportModule.createModuleItemsEmitter () and env = initialEnv in @@ -704,7 +697,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations |> emitCodeItems ~config ~emitters ~moduleItemsEmitter ~env ~fileName ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized:(typeGetNormalized_ ~env) - ~typeGetConverter:(typeGetConverter_ ~env) ~typeNameIsInterface:(typeNameIsInterface ~env) in let emitters = diff --git a/jscomp/gentype/ExportModule.ml b/jscomp/gentype/ExportModule.ml index a61c132c4a..467166f143 100644 --- a/jscomp/gentype/ExportModule.ml +++ b/jscomp/gentype/ExportModule.ml @@ -2,9 +2,7 @@ open GenTypeCommon type exportModuleItem = (string, exportModuleValue) Hashtbl.t -and exportModuleValue = - | S of string * type_ * Converter.t - | M of exportModuleItem +and exportModuleValue = S of string * type_ | M of exportModuleItem type exportModuleItems = (string, exportModuleItem) Hashtbl.t @@ -14,7 +12,7 @@ type fieldInfo = {fieldForValue: field; fieldForType: field} let rec exportModuleValueToType ~config exportModuleValue = match exportModuleValue with - | S (s, type_, _converter) -> {typeForValue = ident s; typeForType = type_} + | S (s, type_) -> {typeForValue = ident s; typeForType = type_} | M exportModuleItem -> let fieldsInfo = exportModuleItem |> exportModuleItemToFields ~config in let fieldsForValue = @@ -48,12 +46,12 @@ and exportModuleItemToFields = exportModuleItem [] : config:Config.t -> exportModuleItem -> fieldInfo list) -let rec extendExportModuleItem x ~converter - ~(exportModuleItem : exportModuleItem) ~type_ ~valueName = +let rec extendExportModuleItem x ~(exportModuleItem : exportModuleItem) ~type_ + ~valueName = match x with | [] -> () | [fieldName] -> - Hashtbl.replace exportModuleItem fieldName (S (valueName, type_, converter)) + Hashtbl.replace exportModuleItem fieldName (S (valueName, type_)) | fieldName :: rest -> let innerExportModuleItem = match Hashtbl.find exportModuleItem fieldName with @@ -65,11 +63,11 @@ let rec extendExportModuleItem x ~converter innerExportModuleItem in rest - |> extendExportModuleItem ~converter ~exportModuleItem:innerExportModuleItem - ~valueName ~type_ + |> extendExportModuleItem ~exportModuleItem:innerExportModuleItem ~valueName + ~type_ -let extendExportModuleItems x ~converter - ~(exportModuleItems : exportModuleItems) ~type_ ~valueName = +let extendExportModuleItems x ~(exportModuleItems : exportModuleItems) ~type_ + ~valueName = match x with | [] -> assert false | [_valueName] -> () @@ -82,8 +80,7 @@ let extendExportModuleItems x ~converter Hashtbl.replace exportModuleItems moduleName exportModuleItem; exportModuleItem in - rest - |> extendExportModuleItem ~converter ~exportModuleItem ~type_ ~valueName + rest |> extendExportModuleItem ~exportModuleItem ~type_ ~valueName let createModuleItemsEmitter = (fun () -> Hashtbl.create 1 : unit -> exportModuleItems) @@ -101,19 +98,18 @@ let emitAllModuleItems ~config ~emitters ~fileName M exportModuleItem |> exportModuleValueToType ~config in if !Debug.codeItems then Log_.item "EmitModule %s @." moduleName; - let emittedModuleItem = - ModuleName.forInnerModule ~fileName ~innerModuleName:moduleName - |> ModuleName.toString - in - emittedModuleItem - |> EmitType.emitExportConst ~early:false ~config ~emitters - ~name:moduleName ~type_:typeForType - ~typeNameIsInterface:(fun _ -> false)) + let emittedModuleItem = + ModuleName.forInnerModule ~fileName ~innerModuleName:moduleName + |> ModuleName.toString + in + emittedModuleItem + |> EmitType.emitExportConst ~early:false ~config ~emitters + ~name:moduleName ~type_:typeForType ~typeNameIsInterface:(fun _ -> + false)) exportModuleItems -let extendExportModules ~converter ~(moduleItemsEmitter : exportModuleItems) - ~type_ resolvedName = +let extendExportModules ~(moduleItemsEmitter : exportModuleItems) ~type_ + resolvedName = resolvedName |> ResolvedName.toList - |> extendExportModuleItems ~converter ~exportModuleItems:moduleItemsEmitter - ~type_ + |> extendExportModuleItems ~exportModuleItems:moduleItemsEmitter ~type_ ~valueName:(resolvedName |> ResolvedName.toString) From 5271e718dfec91708fb8a0e7621a559c7c08076e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:45:46 +0200 Subject: [PATCH 19/20] Cleanup --- jscomp/gentype/Converter.ml | 27 ++++++--------------- jscomp/gentype/EmitJs.ml | 47 +++++++++++++------------------------ 2 files changed, 23 insertions(+), 51 deletions(-) diff --git a/jscomp/gentype/Converter.ml b/jscomp/gentype/Converter.ml index f8b3c708c6..f31f0b602a 100644 --- a/jscomp/gentype/Converter.ml +++ b/jscomp/gentype/Converter.ml @@ -1,7 +1,6 @@ open GenTypeCommon -let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface - type0 = +let typeGetInlined ~config ~lookupId ~typeNameIsInterface type0 = let circular = ref "" in let rec visit ~(visited : StringSet.t) type_ = let normalized_ = type_ in @@ -11,9 +10,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface Array (tNormalized, mutable_) | Dict _ -> normalized_ | Function ({argTypes; retType} as function_) -> - let argConverted = - argTypes |> List.map (argTypeToGroupedArgConverter ~visited) - in + let argConverted = argTypes |> List.map (argTypeToGroupedArg ~visited) in let retNormalized = retType |> visit ~visited in Function {function_ with argTypes = argConverted; retType = retNormalized} | GroupOfLabeledArgs _ -> @@ -29,7 +26,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface match name |> lookupId with | {CodeItem.annotation = GenTypeOpaque} -> normalized_ | {annotation = NoGenType} -> normalized_ - | {typeVars; type_} -> ( + | {typeVars; type_} -> let pairs = try List.combine typeVars typeArgs with Invalid_argument _ -> [] in @@ -41,16 +38,10 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface | exception Not_found -> None in let inlined = type_ |> TypeVars.substitute ~f |> visit ~visited in - match inline with - | true -> inlined - | false -> normalized_) + inlined | exception Not_found -> - if inline then - let typeArgs = - typeArgs |> List.map (fun t -> t |> visit ~visited) - in - Ident {builtin = false; name; typeArgs} - else normalized_) + let typeArgs = typeArgs |> List.map (fun t -> t |> visit ~visited) in + Ident {builtin = false; name; typeArgs}) | Null t -> let tNormalized = t |> visit ~visited in Null tNormalized @@ -85,7 +76,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface Variant {variant with payloads = withPayloadConverted} in normalized - and argTypeToGroupedArgConverter ~visited {aName; aType} = + and argTypeToGroupedArg ~visited {aName; aType} = match aType with | GroupOfLabeledArgs fields -> let fieldsConverted = @@ -107,7 +98,3 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface Log_.item "type0:%s \n" (type0 |> EmitType.typeToString ~config ~typeNameIsInterface); normalized - -let typeGetNormalized ~config ~inline ~lookupId ~typeNameIsInterface type_ = - type_ - |> typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface diff --git a/jscomp/gentype/EmitJs.ml b/jscomp/gentype/EmitJs.ml index 3caedf3952..57843bbc55 100644 --- a/jscomp/gentype/EmitJs.ml +++ b/jscomp/gentype/EmitJs.ml @@ -68,7 +68,7 @@ let codeItemToString ~config ~typeNameIsInterface (codeItem : CodeItem.t) = | ImportValue {importAnnotation} -> "ImportValue " ^ (importAnnotation.importPath |> ImportPath.dump) -let emitExportType ~emitters ~config ~typeGetNormalized ~typeNameIsInterface +let emitExportType ~emitters ~config ~typeNameIsInterface {CodeItem.loc; nameAs; opaque; type_; typeVars; resolvedTypeName} = let freeTypeVars = TypeVars.free type_ in let isGADT = @@ -86,12 +86,10 @@ let emitExportType ~emitters ~config ~typeGetNormalized ~typeNameIsInterface Some true | _ -> opaque in - let opaque, type_ = + let opaque = match opaque with - | Some opaque -> (opaque, type_) - | None -> - let normalized = type_ |> typeGetNormalized in - (false, normalized) + | Some opaque -> opaque + | None -> false in resolvedTypeName |> ResolvedName.toString |> EmitType.emitExportType ~config ~emitters ~nameAs ~opaque ~type_ @@ -111,26 +109,24 @@ let typeNameIsInterface ~(exportTypeMap : CodeItem.exportTypeMap) | {type_} -> type_ |> typeIsInterface | exception Not_found -> false) -let emitExportFromTypeDeclaration ~config ~emitters ~typeGetNormalized ~env - ~typeNameIsInterface +let emitExportFromTypeDeclaration ~config ~emitters ~env ~typeNameIsInterface (exportFromTypeDeclaration : CodeItem.exportFromTypeDeclaration) = ( env, exportFromTypeDeclaration.exportType - |> emitExportType ~emitters ~config ~typeGetNormalized ~typeNameIsInterface - ) + |> emitExportType ~emitters ~config ~typeNameIsInterface ) -let emitExportFromTypeDeclarations ~config ~emitters ~env ~typeGetNormalized - ~typeNameIsInterface exportFromTypeDeclarations = +let emitExportFromTypeDeclarations ~config ~emitters ~env ~typeNameIsInterface + exportFromTypeDeclarations = exportFromTypeDeclarations |> List.fold_left (fun (env, emitters) -> - emitExportFromTypeDeclaration ~config ~emitters ~env ~typeGetNormalized + emitExportFromTypeDeclaration ~config ~emitters ~env ~typeNameIsInterface) (env, emitters) let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName - ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized - ~typeNameIsInterface codeItem = + ~outputFileRelative ~resolver ~inlineOneLevel ~typeNameIsInterface codeItem + = if !Debug.codeItems then Log_.item "Code Item: %s\n" (codeItem |> codeItemToString ~config ~typeNameIsInterface); @@ -387,8 +383,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName in (* For doc gen (https://github.com/cristianoc/genType/issues/342) *) config.emitImportReact <- true; - emitExportType ~emitters ~config ~typeGetNormalized ~typeNameIsInterface - exportType + emitExportType ~emitters ~config ~typeNameIsInterface exportType | _ -> emitters in let emitters = @@ -407,14 +402,12 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName (envWithRequires, emitters) let emitCodeItems ~config ~outputFileRelative ~emitters ~moduleItemsEmitter ~env - ~fileName ~resolver ~typeNameIsInterface ~inlineOneLevel ~typeGetNormalized - codeItems = + ~fileName ~resolver ~typeNameIsInterface ~inlineOneLevel codeItems = codeItems |> List.fold_left (fun (env, emitters) -> emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName - ~outputFileRelative ~resolver ~inlineOneLevel ~typeGetNormalized - ~typeNameIsInterface) + ~outputFileRelative ~resolver ~inlineOneLevel ~typeNameIsInterface) (env, emitters) let emitRequires ~importedValueOrComponent ~early ~config ~requires emitters = @@ -427,7 +420,7 @@ let emitRequires ~importedValueOrComponent ~early ~config ~requires emitters = let typeGetInlined ~config ~exportTypeMap type_ = type_ - |> Converter.typeGetNormalized ~config ~inline:true + |> Converter.typeGetInlined ~config ~lookupId:(fun s -> exportTypeMap |> StringMap.find s) ~typeNameIsInterface:(fun _ -> false) @@ -651,12 +644,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations try exportTypeMap |> StringMap.find s with Not_found -> env.exportTypeMapFromOtherFiles |> StringMap.find s in - let typeGetNormalized__ ~inline ~env type_ = - type_ - |> Converter.typeGetNormalized ~config ~inline ~lookupId:(lookupId_ ~env) - ~typeNameIsInterface:(typeNameIsInterface ~env) - in - let typeGetNormalized_ = typeGetNormalized__ ~inline:false in let emitters = Emitters.initial and moduleItemsEmitter = ExportModule.createModuleItemsEmitter () and env = initialEnv in @@ -669,8 +656,7 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations in let env, emitters = exportFromTypeDeclarations - |> emitExportFromTypeDeclarations ~config ~emitters - ~typeGetNormalized:(typeGetNormalized_ ~env) ~env + |> emitExportFromTypeDeclarations ~config ~emitters ~env ~typeNameIsInterface:(typeNameIsInterface ~env) in let inlineOneLevel type_ = @@ -696,7 +682,6 @@ let emitTranslationAsString ~config ~fileName ~inputCmtTranslateTypeDeclarations translation.codeItems |> emitCodeItems ~config ~emitters ~moduleItemsEmitter ~env ~fileName ~outputFileRelative ~resolver ~inlineOneLevel - ~typeGetNormalized:(typeGetNormalized_ ~env) ~typeNameIsInterface:(typeNameIsInterface ~env) in let emitters = From 3fa066b40d599284291cdc0cdd18e4893847d603 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 28 Mar 2023 09:48:25 +0200 Subject: [PATCH 20/20] Dead code. --- jscomp/gentype/EmitText.ml | 14 -------------- jscomp/gentype/EmitType.ml | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/jscomp/gentype/EmitText.ml b/jscomp/gentype/EmitText.ml index 46418670fd..9ec5c1ec3b 100644 --- a/jscomp/gentype/EmitText.ml +++ b/jscomp/gentype/EmitText.ml @@ -1,27 +1,13 @@ type nameGen = (string, int) Hashtbl.t -let name ~nameGen s = - match Hashtbl.find nameGen s with - | n -> - Hashtbl.replace nameGen s (n + 1); - s ^ string_of_int (n + 1) - | exception Not_found -> - Hashtbl.replace nameGen s 0; - s - let parens xs = "(" ^ (xs |> String.concat ", ") ^ ")" let comment x = "/* " ^ x ^ " */" - let genericsString ~typeVars = match typeVars == [] with | true -> "" | false -> "<" ^ String.concat "," typeVars ^ ">" - -let newNameGen () = Hashtbl.create 1 let quotes x = "\"" ^ x ^ "\"" -let addComment ~comment x = "\n/* " ^ comment ^ " */\n " ^ x -let arrayAccess ~index value = value ^ "[" ^ string_of_int index ^ "]" let fieldAccess ~label value = value ^ "." ^ label diff --git a/jscomp/gentype/EmitType.ml b/jscomp/gentype/EmitType.ml index 0c43247c4d..caa4756f77 100644 --- a/jscomp/gentype/EmitType.ml +++ b/jscomp/gentype/EmitType.ml @@ -307,7 +307,7 @@ and renderFunType ~config ~indent ~inFunType ~typeNameIsInterface ~typeVars let typeToString ~config ~typeNameIsInterface type_ = type_ |> renderType ~config ~typeNameIsInterface ~inFunType:false -let ofType ~config ?(typeNameIsInterface = fun _ -> false) ~type_ s = +let ofType ~config ~typeNameIsInterface ~type_ s = s ^ ": " ^ (type_ |> typeToString ~config ~typeNameIsInterface) let emitExportConst ~early ?(comment = "") ~config ?(docString = "") ~emitters @@ -444,7 +444,5 @@ let emitImportTypeAs ~emitters ~config ~typeName ~asTypeName ^ "} from '" ^ importPathString ^ "';" |> Emitters.import ~emitters -let ofTypeAny ~config s = s |> ofType ~config ~type_:typeAny - let emitTypeCast ~config ~type_ ~typeNameIsInterface s = s ^ " as " ^ (type_ |> typeToString ~config ~typeNameIsInterface)