Skip to content

Commit

Permalink
Support inline records
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Mar 21, 2023
1 parent 4858bdb commit 6e033c9
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
if p.num_nonconst = 1 then tails
else
( Js_op.Lit L.tag,
if !Js_config.debug then tag else { tag with comment = Some p.name }
E.str p.name
)
:: tails
in
Expand Down
8 changes: 4 additions & 4 deletions jscomp/test/inline_record_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/large_record_duplication_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,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 */0,
TAG: "A0",
x0: 9,
x1: 9,
x2: 9,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/rec_value_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function ptl(l) {
var y00 = {};

Caml_obj.update_dummy(y00, {
TAG: /* C1 */1,
TAG: "C1",
hd: 1,
tail: y00
});
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/record_extension_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function f2_with(x) {
return x;
} else {
return {
TAG: /* C */0,
TAG: "C",
x: 0,
y: x.y
};
Expand Down
8 changes: 4 additions & 4 deletions jscomp/test/record_regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,28 @@ function setAA(ao) {
}

var ir0 = {
TAG: /* V0 */0,
TAG: "V0",
x0: "v0",
x3: 3
};

var ir1 = {
TAG: /* V0 */0,
TAG: "V0",
x0: "v0",
x1: "v1",
x3: 3
};

var ir2 = {
TAG: /* V0 */0,
TAG: "V0",
x0: "v0",
x1: "v1",
x2: 2,
x3: 3
};

var ir3 = {
TAG: /* V1 */1,
TAG: "V1",
y0: "v0",
y1: 1
};
Expand Down
76 changes: 38 additions & 38 deletions lib/es6/arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function help_action(param) {
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Unknown */0,
TAG: "Unknown",
_0: "-help"
},
Error: new Error()
Expand All @@ -82,7 +82,7 @@ function add_help(speclist) {
hd: [
"-help",
{
TAG: /* Unit */0,
TAG: "Unit",
_0: help_action
},
" Display this list of options"
Expand All @@ -105,7 +105,7 @@ function add_help(speclist) {
hd: [
"--help",
{
TAG: /* Unit */0,
TAG: "Unit",
_0: help_action
},
" Display this list of options"
Expand All @@ -128,7 +128,7 @@ function usage_b(buf, speclist, errmsg) {
}
var spec = param[1];
var key = param[0];
if (spec.TAG !== /* Symbol */11) {
if (spec.TAG !== "Symbol") {
return $$Buffer.add_string(buf, " " + key + " " + doc + "\n");
}
var sym = make_symlist("{", "|", "}", spec._0);
Expand Down Expand Up @@ -194,8 +194,8 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
var convert_error = function (error) {
var b = $$Buffer.create(200);
var progname = initpos < argv.contents.length ? Caml_array.get(argv.contents, initpos) : "(?)";
switch (error.TAG | 0) {
case /* Unknown */0 :
switch (error.TAG) {
case "Unknown" :
var s = error._0;
switch (s) {
case "--help" :
Expand All @@ -205,23 +205,23 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
$$Buffer.add_string(b, progname + ": unknown option '" + s + "'.\n");
}
break;
case /* Wrong */1 :
case "Wrong" :
$$Buffer.add_string(b, progname + ": wrong argument '" + error._1 + "'; option '" + error._0 + "' expects " + error._2 + ".\n");
break;
case /* Missing */2 :
case "Missing" :
$$Buffer.add_string(b, progname + ": option '" + error._0 + "' needs an argument.\n");
break;
case /* Message */3 :
case "Message" :
$$Buffer.add_string(b, progname + ": " + error._0 + ".\n");
break;

}
usage_b(b, speclist.contents, errmsg);
if (Caml_obj.equal(error, {
TAG: /* Unknown */0,
TAG: "Unknown",
_0: "-help"
}) || Caml_obj.equal(error, {
TAG: /* Unknown */0,
TAG: "Unknown",
_0: "--help"
})) {
return {
Expand Down Expand Up @@ -263,7 +263,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Unknown */0,
TAG: "Unknown",
_0: s
},
Error: new Error()
Expand All @@ -284,7 +284,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: follow,
_2: "no argument"
Expand All @@ -304,7 +304,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Missing */2,
TAG: "Missing",
_0: s
},
Error: new Error()
Expand All @@ -323,10 +323,10 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
}(follow));
var treat_action = (function(s){
return function treat_action(f) {
switch (f.TAG | 0) {
case /* Unit */0 :
switch (f.TAG) {
case "Unit" :
return Curry._1(f._0, undefined);
case /* Bool */1 :
case "Bool" :
var arg = get_arg(undefined);
var s$1 = bool_of_string_opt(arg);
if (s$1 !== undefined) {
Expand All @@ -335,7 +335,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg,
_2: "a boolean"
Expand All @@ -344,22 +344,22 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
};
}
return consume_arg(undefined);
case /* Set */2 :
case "Set" :
no_arg(undefined);
f._0.contents = true;
return ;
case /* Clear */3 :
case "Clear" :
no_arg(undefined);
f._0.contents = false;
return ;
case /* String */4 :
case "String" :
var arg$1 = get_arg(undefined);
Curry._1(f._0, arg$1);
return consume_arg(undefined);
case /* Set_string */5 :
case "Set_string" :
f._0.contents = get_arg(undefined);
return consume_arg(undefined);
case /* Int */6 :
case "Int" :
var arg$2 = get_arg(undefined);
var x = int_of_string_opt(arg$2);
if (x !== undefined) {
Expand All @@ -368,7 +368,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg$2,
_2: "an integer"
Expand All @@ -377,7 +377,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
};
}
return consume_arg(undefined);
case /* Set_int */7 :
case "Set_int" :
var arg$3 = get_arg(undefined);
var x$1 = int_of_string_opt(arg$3);
if (x$1 !== undefined) {
Expand All @@ -386,7 +386,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg$3,
_2: "an integer"
Expand All @@ -395,7 +395,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
};
}
return consume_arg(undefined);
case /* Float */8 :
case "Float" :
var arg$4 = get_arg(undefined);
var x$2 = float_of_string_opt(arg$4);
if (x$2 !== undefined) {
Expand All @@ -404,7 +404,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg$4,
_2: "a float"
Expand All @@ -413,7 +413,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
};
}
return consume_arg(undefined);
case /* Set_float */9 :
case "Set_float" :
var arg$5 = get_arg(undefined);
var x$3 = float_of_string_opt(arg$5);
if (x$3 !== undefined) {
Expand All @@ -422,7 +422,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg$5,
_2: "a float"
Expand All @@ -431,9 +431,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
};
}
return consume_arg(undefined);
case /* Tuple */10 :
case "Tuple" :
return List.iter(treat_action, f._0);
case /* Symbol */11 :
case "Symbol" :
var symb = f._0;
var arg$6 = get_arg(undefined);
if (List.mem(arg$6, symb)) {
Expand All @@ -443,21 +443,21 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
throw {
RE_EXN_ID: Stop,
_1: {
TAG: /* Wrong */1,
TAG: "Wrong",
_0: s,
_1: arg$6,
_2: "one of: " + make_symlist("", " ", "", symb)
},
Error: new Error()
};
case /* Rest */12 :
case "Rest" :
var f$1 = f._0;
while(current.contents < (argv.contents.length - 1 | 0)) {
Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0));
consume_arg(undefined);
};
return ;
case /* Expand */13 :
case "Expand" :
if (!allow_expand) {
throw {
RE_EXN_ID: "Invalid_argument",
Expand Down Expand Up @@ -494,7 +494,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
var m = Caml_js_exceptions.internalToOCamlException(raw_m);
if (m.RE_EXN_ID === Bad) {
throw convert_error({
TAG: /* Message */3,
TAG: "Message",
_0: m._1
});
}
Expand Down Expand Up @@ -636,7 +636,7 @@ function second_word(s) {

function max_arg_len(cur, param) {
var kwd = param[0];
if (param[1].TAG === /* Symbol */11) {
if (param[1].TAG === "Symbol") {
return Caml.int_max(cur, kwd.length);
} else {
return Caml.int_max(cur, kwd.length + second_word(param[2]) | 0);
Expand Down Expand Up @@ -668,7 +668,7 @@ function align(limitOpt, speclist) {
if (param[2] === "") {
return param;
}
if (spec.TAG === /* Symbol */11) {
if (spec.TAG === "Symbol") {
var msg = param[2];
var cutcol = second_word(msg);
var spaces = " ".repeat(Caml.int_max(0, len$1 - cutcol | 0) + 3 | 0);
Expand Down

0 comments on commit 6e033c9

Please sign in to comment.