File tree 9 files changed +26
-47
lines changed
9 files changed +26
-47
lines changed Original file line number Diff line number Diff line change @@ -794,28 +794,23 @@ and expression_desc cxt ~(level : int) f x : cxt =
794
794
let untagged = Ast_untagged_variants. process_untagged p.attrs in
795
795
let objs =
796
796
let tails =
797
- Ext_list. combine_array_append p.fields el
798
- (if ! Js_config. debug then [(name_symbol, E. str p.name)] else [] )
799
- (fun i -> Js_op. Lit i)
800
- in
801
- let is_optional (pname : Js_op.property_name ) =
802
- match pname with
803
- | Lit n -> Ext_list. mem_string p.optional_labels n
804
- | Symbol_name -> false
797
+ Ext_list. combine_array p.fields el (fun (i , opt ) -> (Js_op. Lit i, opt))
805
798
in
799
+ (* let is_optional (pname : Js_op.property_name) =
800
+ match pname with
801
+ | Lit n -> Ext_list.mem_string p.optional_labels n
802
+ | Symbol_name -> false
803
+ in *)
806
804
let tag_name =
807
805
match Ast_untagged_variants. process_tag_name p.attrs with
808
806
| None -> L. tag
809
807
| Some s -> s
810
808
in
811
809
let tails =
812
- match p.optional_labels with
813
- | [] -> tails
814
- | _ ->
815
- Ext_list. filter_map tails (fun (f , x ) ->
816
- match x.expression_desc with
817
- | Undefined _ when is_optional f -> None
818
- | _ -> Some (f, x))
810
+ Ext_list. filter_map tails (fun ((f , optional ), x ) ->
811
+ match x.expression_desc with
812
+ | Undefined _ when optional -> None
813
+ | _ -> Some (f, x))
819
814
in
820
815
if untagged then tails
821
816
else
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ let compile output_prefix =
427
427
(match tag_info with
428
428
| Blk_record {fields = xs } -> Fld_record_set xs.(i)
429
429
| Blk_record_inlined xs ->
430
- Fld_record_inline_set xs.fields.(i)
430
+ Fld_record_inline_set (fst xs.fields.(i) )
431
431
| Blk_constructor p -> (
432
432
let is_cons = p.name = Literals. cons in
433
433
match (is_cons, i) with
Original file line number Diff line number Diff line change @@ -128,13 +128,6 @@ let constructor_descrs ty_path decl cstrs =
128
128
describe_constructors idx_const (idx_nonconst + 1 ) rem )
129
129
in
130
130
let cstr_name = Ident. name cd_id in
131
- let optional_labels =
132
- match cd_args with
133
- | Cstr_tuple _ -> []
134
- | Cstr_record lbls ->
135
- Ext_list. filter_map lbls (fun {ld_id; ld_optional} ->
136
- if ld_optional then Some ld_id.name else None )
137
- in
138
131
let existentials, cstr_args, cstr_inlined =
139
132
let representation =
140
133
if decl.type_unboxed.unboxed then Record_unboxed true
@@ -144,7 +137,6 @@ let constructor_descrs ty_path decl cstrs =
144
137
tag = idx_nonconst;
145
138
name = cstr_name;
146
139
num_nonconsts = ! num_nonconsts;
147
- optional_labels;
148
140
attrs = cd_attributes;
149
141
}
150
142
in
Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ type tag_info =
28
28
name : string ;
29
29
num_nonconst : int ;
30
30
tag : int ;
31
- optional_labels : string list ;
32
- fields : string array ;
31
+ fields : (string * bool (* optional *) ) array ;
33
32
mutable_flag : Asttypes .mutable_flag ;
34
33
attrs : Parsetree .attributes ;
35
34
}
@@ -104,16 +103,15 @@ let blk_record_ext fields mutable_flag =
104
103
in
105
104
Blk_record_ext {fields = all_labels_info; mutable_flag}
106
105
107
- let blk_record_inlined fields name num_nonconst optional_labels ~tag ~attrs
108
- mutable_flag =
106
+ let blk_record_inlined fields name num_nonconst ~tag ~attrs mutable_flag =
109
107
let fields =
110
108
Array. map
111
109
(fun ((lbl : label ), _ ) ->
112
- Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
110
+ ( Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name,
111
+ lbl.lbl_optional ))
113
112
fields
114
113
in
115
- Blk_record_inlined
116
- {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs}
114
+ Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; attrs}
117
115
118
116
let ref_tag_info : tag_info =
119
117
Blk_record
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ type tag_info =
32
32
name : string ;
33
33
num_nonconst : int ;
34
34
tag : int ;
35
- optional_labels : string list ;
36
- fields : string array ;
35
+ fields : (string * bool (* optional *) ) array ;
37
36
mutable_flag : mutable_flag ;
38
37
attrs : Parsetree .attributes ;
39
38
}
@@ -81,7 +80,6 @@ val blk_record_inlined :
81
80
(Types .label_description * Typedtree .record_label_definition ) array ->
82
81
string ->
83
82
int ->
84
- string list ->
85
83
tag :int ->
86
84
attrs :Parsetree .attributes ->
87
85
mutable_flag ->
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ let print_taginfo ppf = function
104
104
| Blk_lazy_general -> fprintf ppf " lazy_general"
105
105
| Blk_module_export _ -> fprintf ppf " module/exports"
106
106
| Blk_record_inlined {fields = ss } ->
107
- fprintf ppf " [%s]" (String. concat " ;" (Array. to_list ss))
107
+ fprintf ppf " [%s]" (String. concat " ;" (List. map fst ( Array. to_list ss) ))
108
108
109
109
let primitive ppf = function
110
110
| Pidentity -> fprintf ppf " id"
Original file line number Diff line number Diff line change @@ -1217,11 +1217,11 @@ and transl_record loc env fields repres opt_init_expr =
1217
1217
| Record_optional_labels ->
1218
1218
Lconst
1219
1219
(Const_block (Lambda. blk_record fields mut Record_optional , cl))
1220
- | Record_inlined {tag; name; num_nonconsts; optional_labels; attrs} ->
1220
+ | Record_inlined {tag; name; num_nonconsts; attrs} ->
1221
1221
Lconst
1222
1222
(Const_block
1223
- ( Lambda. blk_record_inlined fields name num_nonconsts
1224
- optional_labels ~tag ~attrs mut,
1223
+ ( Lambda. blk_record_inlined fields name num_nonconsts ~tag
1224
+ ~attrs mut,
1225
1225
cl ))
1226
1226
| Record_unboxed _ ->
1227
1227
Lconst
@@ -1240,11 +1240,11 @@ and transl_record loc env fields repres opt_init_expr =
1240
1240
ll,
1241
1241
loc )
1242
1242
| Record_float_unused -> assert false
1243
- | Record_inlined {tag; name; num_nonconsts; optional_labels; attrs} ->
1243
+ | Record_inlined {tag; name; num_nonconsts; attrs} ->
1244
1244
Lprim
1245
1245
( Pmakeblock
1246
- (Lambda. blk_record_inlined fields name num_nonconsts
1247
- optional_labels ~tag ~attrs mut),
1246
+ (Lambda. blk_record_inlined fields name num_nonconsts ~tag
1247
+ ~attrs mut),
1248
1248
ll,
1249
1249
loc )
1250
1250
| Record_unboxed _ -> (
Original file line number Diff line number Diff line change @@ -153,7 +153,6 @@ and record_representation =
153
153
tag : int ;
154
154
name : string ;
155
155
num_nonconsts : int ;
156
- optional_labels : string list ;
157
156
attrs : Parsetree .attributes ;
158
157
}
159
158
| Record_extension (* Inlined record under extension *)
@@ -315,12 +314,10 @@ let same_record_representation x y =
315
314
match y with
316
315
| Record_optional_labels -> true
317
316
| _ -> false )
318
- | Record_inlined {tag; name; num_nonconsts; optional_labels } -> (
317
+ | Record_inlined {tag; name; num_nonconsts} -> (
319
318
match y with
320
319
| Record_inlined y ->
321
- tag = y.tag && name = y.name
322
- && num_nonconsts = y.num_nonconsts
323
- && optional_labels = y.optional_labels
320
+ tag = y.tag && name = y.name && num_nonconsts = y.num_nonconsts
324
321
| _ -> false )
325
322
| Record_extension -> y = Record_extension
326
323
| Record_unboxed x -> (
Original file line number Diff line number Diff line change @@ -281,7 +281,6 @@ and record_representation =
281
281
tag : int ;
282
282
name : string ;
283
283
num_nonconsts : int ;
284
- optional_labels : string list ;
285
284
attrs : Parsetree .attributes ;
286
285
}
287
286
| Record_extension (* Inlined record under extension *)
You can’t perform that action at this time.
0 commit comments