@@ -86,21 +86,47 @@ let mutable_flag_of_tag_info (tag : tag_info) =
86
86
| Blk_some
87
87
-> Immutable
88
88
89
+ type label = Types .label_description
90
+
91
+ let find_name (attr : Parsetree.attribute ) =
92
+ match attr with
93
+ | ( { txt = " bs.as" | " as" },
94
+ PStr
95
+ [
96
+ {
97
+ pstr_desc =
98
+ Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string (s, _)) }, _);
99
+ };
100
+ ] ) ->
101
+ Some s
102
+ | _ -> None
103
+
104
+ let blk_record (fields : (label * _) array ) mut record_repr =
105
+ let all_labels_info =
106
+ Ext_array. map fields (fun (lbl , _ ) ->
107
+ Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
108
+ in
109
+ Blk_record
110
+ { fields = all_labels_info; mutable_flag = mut; record_repr }
89
111
90
- let blk_record = ref (fun _ _ _ ->
91
- assert false
92
- )
93
-
94
-
95
- let blk_record_ext = ref (fun fields mutable_flag ->
96
- let all_labels_info = fields |> Array. map (fun (x ,_ ) -> x.Types. lbl_name) in
97
- Blk_record_ext {fields = all_labels_info; mutable_flag }
98
- )
99
112
100
- let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag ~attrs mutable_flag ->
101
- let fields = fields |> Array. map (fun (x ,_ ) -> x.Types. lbl_name) in
113
+ let blk_record_ext fields mutable_flag =
114
+ let all_labels_info =
115
+ Array. map
116
+ (fun ((lbl : label ), _ ) ->
117
+ Ext_list. find_def lbl.Types. lbl_attributes find_name lbl.lbl_name)
118
+ fields
119
+ in
120
+ Blk_record_ext {fields = all_labels_info; mutable_flag }
121
+
122
+ let blk_record_inlined fields name num_nonconst optional_labels ~tag ~attrs mutable_flag =
123
+ let fields =
124
+ Array. map
125
+ (fun ((lbl : label ), _ ) ->
126
+ Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
127
+ fields
128
+ in
102
129
Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs }
103
- )
104
130
105
131
let ref_tag_info : tag_info =
106
132
Blk_record {fields = [| " contents" |]; mutable_flag = Mutable ; record_repr = Record_regular }
@@ -117,15 +143,17 @@ type field_dbg_info =
117
143
| Fld_variant
118
144
| Fld_cons
119
145
| Fld_array
120
-
121
- let fld_record = ref (fun (lbl : Types.label_description ) ->
122
- Fld_record {name = lbl.lbl_name; mutable_flag = Mutable })
123
146
124
- let fld_record_inline = ref (fun (lbl : Types.label_description ) ->
125
- Fld_record_inline {name = lbl.lbl_name})
147
+ let fld_record (lbl : label ) =
148
+ Fld_record
149
+ {
150
+ name = Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name;
151
+ mutable_flag = lbl.lbl_mut;
152
+ }
126
153
127
- let fld_record_extension = ref (fun (lbl : Types.label_description ) ->
128
- Fld_record_extension {name = lbl.lbl_name})
154
+ let fld_record_extension (lbl : label ) =
155
+ Fld_record_extension
156
+ { name = Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name }
129
157
130
158
let ref_field_info : field_dbg_info =
131
159
Fld_record { name = " contents" ; mutable_flag = Mutable }
@@ -137,14 +165,21 @@ type set_field_dbg_info =
137
165
| Fld_record_extension_set of string
138
166
139
167
let ref_field_set_info : set_field_dbg_info = Fld_record_set " contents"
140
- let fld_record_set = ref ( fun (lbl : Types.label_description ) ->
141
- Fld_record_set lbl.lbl_name )
168
+ let fld_record_set (lbl : label ) =
169
+ Fld_record_set
170
+ (Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
171
+
172
+ let fld_record_inline (lbl : label ) =
173
+ Fld_record_inline
174
+ { name = Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name }
142
175
143
- let fld_record_inline_set = ref ( fun (lbl : Types.label_description ) ->
144
- Fld_record_inline_set lbl.lbl_name )
176
+ let fld_record_inline_set (lbl : label ) =
177
+ Fld_record_inline_set
178
+ (Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
145
179
146
- let fld_record_extension_set = ref ( fun (lbl : Types.label_description ) ->
147
- Fld_record_extension_set lbl.lbl_name )
180
+ let fld_record_extension_set (lbl : label ) =
181
+ Fld_record_extension_set
182
+ (Ext_list. find_def lbl.lbl_attributes find_name lbl.lbl_name)
148
183
149
184
type immediate_or_pointer =
150
185
| Immediate
0 commit comments