File tree Expand file tree Collapse file tree 9 files changed +26
-47
lines changed
Expand file tree Collapse file tree 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 =
794794 let untagged = Ast_untagged_variants. process_untagged p.attrs in
795795 let objs =
796796 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))
805798 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 *)
806804 let tag_name =
807805 match Ast_untagged_variants. process_tag_name p.attrs with
808806 | None -> L. tag
809807 | Some s -> s
810808 in
811809 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))
819814 in
820815 if untagged then tails
821816 else
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ let compile output_prefix =
427427 (match tag_info with
428428 | Blk_record {fields = xs } -> Fld_record_set xs.(i)
429429 | Blk_record_inlined xs ->
430- Fld_record_inline_set xs.fields.(i)
430+ Fld_record_inline_set (fst xs.fields.(i) )
431431 | Blk_constructor p -> (
432432 let is_cons = p.name = Literals. cons in
433433 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 =
128128 describe_constructors idx_const (idx_nonconst + 1 ) rem )
129129 in
130130 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
138131 let existentials, cstr_args, cstr_inlined =
139132 let representation =
140133 if decl.type_unboxed.unboxed then Record_unboxed true
@@ -144,7 +137,6 @@ let constructor_descrs ty_path decl cstrs =
144137 tag = idx_nonconst;
145138 name = cstr_name;
146139 num_nonconsts = ! num_nonconsts;
147- optional_labels;
148140 attrs = cd_attributes;
149141 }
150142 in
Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ type tag_info =
2828 name : string ;
2929 num_nonconst : int ;
3030 tag : int ;
31- optional_labels : string list ;
32- fields : string array ;
31+ fields : (string * bool (* optional *) ) array ;
3332 mutable_flag : Asttypes .mutable_flag ;
3433 attrs : Parsetree .attributes ;
3534 }
@@ -104,16 +103,15 @@ let blk_record_ext fields mutable_flag =
104103 in
105104 Blk_record_ext {fields = all_labels_info; mutable_flag}
106105
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 =
109107 let fields =
110108 Array. map
111109 (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 ))
113112 fields
114113 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}
117115
118116let ref_tag_info : tag_info =
119117 Blk_record
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ type tag_info =
3232 name : string ;
3333 num_nonconst : int ;
3434 tag : int ;
35- optional_labels : string list ;
36- fields : string array ;
35+ fields : (string * bool (* optional *) ) array ;
3736 mutable_flag : mutable_flag ;
3837 attrs : Parsetree .attributes ;
3938 }
@@ -81,7 +80,6 @@ val blk_record_inlined :
8180 (Types .label_description * Typedtree .record_label_definition ) array ->
8281 string ->
8382 int ->
84- string list ->
8583 tag :int ->
8684 attrs :Parsetree .attributes ->
8785 mutable_flag ->
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ let print_taginfo ppf = function
104104 | Blk_lazy_general -> fprintf ppf " lazy_general"
105105 | Blk_module_export _ -> fprintf ppf " module/exports"
106106 | 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) ))
108108
109109let primitive ppf = function
110110 | 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 =
12171217 | Record_optional_labels ->
12181218 Lconst
12191219 (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} ->
12211221 Lconst
12221222 (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,
12251225 cl ))
12261226 | Record_unboxed _ ->
12271227 Lconst
@@ -1240,11 +1240,11 @@ and transl_record loc env fields repres opt_init_expr =
12401240 ll,
12411241 loc )
12421242 | Record_float_unused -> assert false
1243- | Record_inlined {tag; name; num_nonconsts; optional_labels; attrs} ->
1243+ | Record_inlined {tag; name; num_nonconsts; attrs} ->
12441244 Lprim
12451245 ( 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),
12481248 ll,
12491249 loc )
12501250 | Record_unboxed _ -> (
Original file line number Diff line number Diff line change @@ -153,7 +153,6 @@ and record_representation =
153153 tag : int ;
154154 name : string ;
155155 num_nonconsts : int ;
156- optional_labels : string list ;
157156 attrs : Parsetree .attributes ;
158157 }
159158 | Record_extension (* Inlined record under extension *)
@@ -315,12 +314,10 @@ let same_record_representation x y =
315314 match y with
316315 | Record_optional_labels -> true
317316 | _ -> false )
318- | Record_inlined {tag; name; num_nonconsts; optional_labels } -> (
317+ | Record_inlined {tag; name; num_nonconsts} -> (
319318 match y with
320319 | 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
324321 | _ -> false )
325322 | Record_extension -> y = Record_extension
326323 | Record_unboxed x -> (
Original file line number Diff line number Diff line change @@ -281,7 +281,6 @@ and record_representation =
281281 tag : int ;
282282 name : string ;
283283 num_nonconsts : int ;
284- optional_labels : string list ;
285284 attrs : Parsetree .attributes ;
286285 }
287286 | Record_extension (* Inlined record under extension *)
You can’t perform that action at this time.
0 commit comments