Skip to content

Commit a410ff7

Browse files
committed
precise information for Field access, only one spot remaining when compiling classes
1 parent 4579368 commit a410ff7

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

bytecomp/lambda.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ type field_dbg_info =
8181
| Fld_poly_var_content
8282
| Fld_extension
8383
| Fld_variant
84-
84+
| Fld_array
85+
8586
let fld_record = ref (fun (lbl : Types.label_description) ->
8687
Fld_record {name = lbl.lbl_name; mutable_flag = Mutable})
8788

bytecomp/lambda.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ type field_dbg_info =
9797
| Fld_poly_var_content
9898
| Fld_extension
9999
| Fld_variant
100+
| Fld_array
101+
100102
val fld_record :
101103
(Types.label_description ->
102104
field_dbg_info) ref

bytecomp/printlambda.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ let str_of_field_info (fld_info : Lambda.field_dbg_info)=
139139
| Fld_poly_var_content -> "#"
140140
| Fld_extension -> "ext"
141141
| Fld_variant -> "var"
142+
| Fld_array -> "[||]"
142143
let print_taginfo ppf = function
143144
| Blk_extension -> fprintf ppf "ext"
144145
| Blk_record_ext ss -> fprintf ppf "[%s]" (String.concat ";" (Array.to_list ss) )

bytecomp/translclass.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let mkappl (func, args) =
5656
let lsequence l1 l2 =
5757
if l2 = lambda_unit then l1 else Lsequence(l1, l2)
5858

59-
let lfield ?(fld_info=Lambda.fld_na) v i = Lprim(Pfield (i, fld_info), [Lvar v], Location.none)
59+
let lfield ~fld_info v i = Lprim(Pfield (i, fld_info), [Lvar v], Location.none)
6060

6161
let transl_label l = share (Const_immstring l)
6262

@@ -236,7 +236,7 @@ let bind_methods tbl meths vals cl_init =
236236
[Lvar tbl; transl_meth_list (List.map fst methl)] @ names),
237237
List.fold_right
238238
(fun (_lab,id) lam -> decr i; Llet(StrictOpt, Pgenval, id,
239-
lfield ids !i, lam))
239+
lfield ~fld_info:Fld_array ids !i, lam))
240240
(methl @ vals) cl_init)
241241

242242
let output_methods tbl methods lam =
@@ -360,20 +360,20 @@ let rec build_class_init cla cstr super inh_init cl_init msubst top cl =
360360
List.fold_left
361361
(fun init (nm, id, _) ->
362362
Llet(StrictOpt, Pgenval, id,
363-
lfield inh (index nm concr_meths + ofs),
363+
lfield inh (index nm concr_meths + ofs) ~fld_info:Fld_array,
364364
init))
365365
cl_init methids in
366366
let cl_init =
367367
List.fold_left
368368
(fun init (nm, id) ->
369369
Llet(StrictOpt, Pgenval, id,
370-
lfield inh (index nm vals + 1), init))
370+
lfield inh (index nm vals + 1) ~fld_info:Fld_array, init))
371371
cl_init valids in
372372
(inh_init,
373373
Llet (Strict, Pgenval, inh,
374374
mkappl(oo_prim "inherits", narrow_args @
375375
[lpath; Lconst(Const_pointer((if top then 1 else 0),Pt_builtin_boolean))]),
376-
Llet(StrictOpt, Pgenval, obj_init, lfield inh 0, cl_init)))
376+
Llet(StrictOpt, Pgenval, obj_init, lfield inh 0 ~fld_info:Fld_array, cl_init)))
377377
| _ ->
378378
let core cl_init =
379379
build_class_init cla true super inh_init cl_init msubst top cl
@@ -661,7 +661,7 @@ let transl_class ids cl_id pub_meths cl vflag =
661661
let i = ref (i0-1) in
662662
List.fold_left
663663
(fun subst id ->
664-
incr i; Ident.add id (lfield env !i) subst)
664+
incr i; Ident.add id (lfield env !i ~fld_info:Fld_array) subst) (* can not be of type {!tables} since it's either of size 0 or 3 *)
665665
Ident.empty !new_ids'
666666
in
667667
let new_ids_meths = ref [] in
@@ -698,9 +698,9 @@ let transl_class ids cl_id pub_meths cl vflag =
698698
if top then lam else
699699
(* must be called only once! *)
700700
let lam = subst_lambda (subst env1 lam 1 new_ids_init) lam in
701-
Llet(Alias, Pgenval, env1, (if l = [] then Lvar envs else lfield envs 0),
701+
Llet(Alias, Pgenval, env1, (if l = [] then Lvar envs else lfield envs 0 ~fld_info:(Fld_na "FLD_NA")),
702702
Llet(Alias, Pgenval, env1',
703-
(if !new_ids_init = [] then Lvar env1 else lfield env1 0),
703+
(if !new_ids_init = [] then Lvar env1 else lfield env1 0 ~fld_info:(Fld_na "FLD_NA")),
704704
lam))
705705
in
706706

0 commit comments

Comments
 (0)