Skip to content

Commit eb3577a

Browse files
committed
Emit tags as strings.
1 parent c584ae8 commit eb3577a

File tree

295 files changed

+8315
-8332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+8315
-8332
lines changed

a.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module I = { type t = int }
2+
type t1 = int => string
3+
type t2 = I.t => string

jscomp/core/js_dump.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
799799
if p.num_nonconst = 1 then tails
800800
else
801801
( Js_op.Lit L.tag,
802-
if !Js_config.debug then tag else { tag with comment = Some p.name }
802+
E.str p.name
803803
)
804804
:: tails
805805
in

jscomp/core/js_exp_make.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ let is_type_number ?comment (e : t) : t =
761761
string_equal ?comment (typeof e) (str "number")
762762

763763
let is_tag (e : t) : t =
764-
string_equal ~comment:"tag" (typeof e) (str "number")
764+
string_equal (typeof e) (str "string")
765765

766766
let is_type_string ?comment (e : t) : t =
767767
string_equal ?comment (typeof e) (str "string")
@@ -774,12 +774,7 @@ let is_type_object (e : t) : t = string_equal (typeof e) (str "object")
774774
*)
775775

776776
let tag ?comment e : t =
777-
{
778-
expression_desc =
779-
Bin
780-
(Bor, { expression_desc = Caml_block_tag e; comment }, zero_int_literal);
781-
comment = None;
782-
}
777+
{ expression_desc = Caml_block_tag e; comment }
783778

784779
(* according to the compiler, [Btype.hash_variant],
785780
it's reduced to 31 bits for hash

jscomp/core/js_of_lam_block.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ module E = Js_exp_make
3030
let make_block mutable_flag (tag_info : Lam_tag_info.t) tag args =
3131
match tag_info with _ -> E.make_block tag tag_info args mutable_flag
3232

33-
(* | _, ( Tuple | Variant _ ) -> (\** TODO: check with inline record *\) *)
34-
(* E.arr Immutable *)
35-
(* (E.small_int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag *)
36-
(* :: args) *)
37-
(* | _, _ -> *)
38-
(* E.arr mutable_flag *)
39-
(* (E.int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag *)
40-
(* :: args) *)
41-
4233
let field (field_info : Lam_compat.field_dbg_info) e (i : int32) =
4334
match field_info with
4435
| Fld_tuple | Fld_array ->

jscomp/core/lam_compile.ml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,17 @@ and compile_general_cases :
568568
[ switch ?default ?declaration switch_exp body ])
569569

570570
and compile_cases cxt (switch_exp : E.t) table default get_name =
571+
let string_table = table |> List.filter_map (fun (i, lam) -> match get_name i
572+
with None -> None
573+
| Some n -> Some (n, lam)) in
574+
if List.length string_table = List.length table
575+
then
576+
compile_string_cases cxt switch_exp string_table default
577+
else
571578
compile_general_cases get_name
572-
(fun i -> { (E.small_int i) with comment = get_name i })
579+
(fun i -> match get_name i with
580+
| None -> E.small_int i
581+
| Some name -> E.str name)
573582
E.int_equal cxt
574583
(fun ?default ?declaration e clauses ->
575584
S.int_switch ?default ?declaration e clauses)

jscomp/core/lam_compile_const.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ and translate (x : Lam_constant.t) : J.expression =
4747
| Const_js_false -> E.bool false
4848
| Const_js_null -> E.nil
4949
| Const_js_undefined -> E.undefined
50+
| Const_int { i; comment = Pt_constructor {name}} when name <> "[]" ->
51+
E.str name
5052
| Const_int { i; comment } ->
5153
E.int i ?comment:(Lam_constant.string_of_pointer_info comment)
5254
| Const_char i -> Js_of_lam_string.const_char i

jscomp/core/lam_compile_util.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,3 @@ let jsop_of_comp (cmp : Lam_compat.comparison) : Js_op.binop =
3030
| Cgt -> Gt
3131
| Cle -> Le
3232
| Cge -> Ge
33-
34-
let comment_of_tag_info (x : Lam_tag_info.t) =
35-
match x with
36-
| Blk_constructor { name = n } -> Some n
37-
| Blk_tuple -> Some "tuple"
38-
| Blk_poly_var _ -> None
39-
| Blk_record _ -> None
40-
| Blk_record_inlined { name = ctor } -> Some ctor
41-
| Blk_record_ext _ -> None
42-
| Blk_module_export _ | Blk_module _ ->
43-
(* Turn it on next time to save some noise diff*)
44-
None
45-
| Blk_extension (* TODO: enhance it later *) -> None
46-
| Blk_some | Blk_some_not_nested | Blk_lazy_general -> assert false
47-
(* let module_alias = Some "alias" *)

jscomp/core/lam_compile_util.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@
2525
(** Some utilities for lambda compilation*)
2626

2727
val jsop_of_comp : Lam_compat.comparison -> Js_op.binop
28-
29-
val comment_of_tag_info : Lam_tag_info.t -> string option

jscomp/test/a_filename_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function eq(loc, x, y) {
1919
loc + (" id " + String(test_id.contents)),
2020
(function (param) {
2121
return {
22-
TAG: /* Eq */0,
22+
TAG: "Eq",
2323
_0: x,
2424
_1: y
2525
};

jscomp/test/a_list_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var suites_0 = [
77
"drop",
88
(function (param) {
99
return {
10-
TAG: /* Eq */0,
10+
TAG: "Eq",
1111
_0: Ext_list_test.drop(3, {
1212
hd: 0,
1313
tl: {
@@ -28,7 +28,7 @@ var suites_1 = {
2828
"drop1",
2929
(function (param) {
3030
return {
31-
TAG: /* Eq */0,
31+
TAG: "Eq",
3232
_0: Ext_list_test.drop(2, {
3333
hd: 0,
3434
tl: {
@@ -51,7 +51,7 @@ var suites_1 = {
5151
"flat_map",
5252
(function (param) {
5353
return {
54-
TAG: /* Eq */0,
54+
TAG: "Eq",
5555
_0: {
5656
hd: 0,
5757
tl: {

jscomp/test/a_string_test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var suites_0 = [
88
"split",
99
(function (param) {
1010
return {
11-
TAG: /* Eq */0,
11+
TAG: "Eq",
1212
_0: Ext_string_test.split(true, "hihi", /* 'i' */105),
1313
_1: {
1414
hd: "h",
@@ -29,7 +29,7 @@ var suites_1 = {
2929
"split_non_empty",
3030
(function (param) {
3131
return {
32-
TAG: /* Eq */0,
32+
TAG: "Eq",
3333
_0: Ext_string_test.split(undefined, "hihi", /* 'i' */105),
3434
_1: {
3535
hd: "h",
@@ -46,7 +46,7 @@ var suites_1 = {
4646
"split_empty",
4747
(function (param) {
4848
return {
49-
TAG: /* Eq */0,
49+
TAG: "Eq",
5050
_0: Ext_string_test.split(true, "", /* 'i' */105),
5151
_1: /* [] */0
5252
};
@@ -57,7 +57,7 @@ var suites_1 = {
5757
"split_normal",
5858
(function (param) {
5959
return {
60-
TAG: /* Eq */0,
60+
TAG: "Eq",
6161
_0: Ext_string_test.split(true, "h i i", /* ' ' */32),
6262
_1: {
6363
hd: "h",
@@ -77,7 +77,7 @@ var suites_1 = {
7777
"split_by",
7878
(function (param) {
7979
return {
80-
TAG: /* Eq */0,
80+
TAG: "Eq",
8181
_0: List.filter(function (s) {
8282
return s !== "";
8383
})(Ext_string_test.split_by(undefined, (function (x) {

0 commit comments

Comments
 (0)