Skip to content

Commit 82576d3

Browse files
committed
clean up with better names
1 parent 83d5562 commit 82576d3

File tree

7 files changed

+44
-40
lines changed

7 files changed

+44
-40
lines changed

bytecomp/lambda.ml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ type loc_kind =
2929
| Loc_POS
3030

3131
type tag_info =
32-
| Constructor of string
33-
| Tuple
34-
| Array
35-
| Variant of string
36-
| Record of string array (* when its empty means we dont get such information *)
37-
| Module of string list option
38-
| NA
32+
| Blk_constructor of string * int (* Number of non-const constructors*)
33+
| Blk_tuple
34+
| Blk_array
35+
| Blk_variant of string
36+
| Blk_record of string array (* when its empty means we dont get such information *)
37+
| Blk_module of string list option
38+
| Blk_na
3939

40-
let default_tag_info : tag_info = NA
40+
let default_tag_info : tag_info = Blk_na
4141

4242
type field_dbg_info =
4343
| Fld_na
@@ -188,11 +188,12 @@ and raise_kind =
188188
| Raise_notrace
189189

190190
type pointer_info =
191-
| NullConstructor of string
192-
| NullVariant of string
193-
| NAPointer
191+
| Pt_constructor of string
192+
| Pt_variant of string
193+
| Pt_module_alias
194+
| Pt_na
194195

195-
let default_pointer_info = NAPointer
196+
let default_pointer_info = Pt_na
196197

197198
type structured_constant =
198199
Const_base of constant
@@ -586,7 +587,7 @@ let lam_of_loc kind loc =
586587
loc_start.Lexing.pos_cnum + cnum in
587588
match kind with
588589
| Loc_POS ->
589-
Lconst (Const_block (0, default_tag_info, [
590+
Lconst (Const_block (0, Blk_tuple, [
590591
Const_immstring file;
591592
Const_base (Const_int lnum);
592593
Const_base (Const_int cnum);

bytecomp/lambda.mli

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ type loc_kind =
3131

3232

3333
type tag_info =
34-
| Constructor of string
35-
| Tuple
36-
| Array
37-
| Variant of string
38-
| Record of string array
39-
| Module of string list option
40-
| NA
34+
| Blk_constructor of string * int (* Number of non-const constructors*)
35+
| Blk_tuple
36+
| Blk_array
37+
| Blk_variant of string
38+
| Blk_record of string array
39+
| Blk_module of string list option
40+
| Blk_na
4141

4242
val default_tag_info : tag_info
4343

@@ -51,9 +51,10 @@ type set_field_dbg_info =
5151
| Fld_record_set of string
5252

5353
type pointer_info =
54-
| NullConstructor of string
55-
| NullVariant of string
56-
| NAPointer
54+
| Pt_constructor of string
55+
| Pt_variant of string
56+
| Pt_module_alias
57+
| Pt_na
5758

5859
val default_pointer_info : pointer_info
5960

bytecomp/translclass.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ let lfield v i = Lprim(Pfield (i, Fld_na), [Lvar v])
4848
let transl_label l = share (Const_immstring l)
4949

5050
let transl_meth_list lst =
51-
if lst = [] then Lconst (Const_pointer (0, Lambda.NAPointer)) else
51+
if lst = [] then Lconst (Const_pointer (0, Lambda.Pt_na)) else
5252
share (Const_block
53-
(0, Lambda.NA, List.map (fun lab -> Const_immstring lab) lst))
53+
(0, Lambda.Blk_na, List.map (fun lab -> Const_immstring lab) lst))
5454

5555
let set_inst_var obj id expr =
5656
let kind = if Typeopt.maybe_pointer expr then Paddrarray else Pintarray in
@@ -236,7 +236,7 @@ let output_methods tbl methods lam =
236236
lsequence (mkappl(oo_prim "set_method", [Lvar tbl; lab; code])) lam
237237
| _ ->
238238
lsequence (mkappl(oo_prim "set_methods",
239-
[Lvar tbl; Lprim(Pmakeblock(0, Lambda.Array, Immutable), methods)]))
239+
[Lvar tbl; Lprim(Pmakeblock(0, Lambda.Blk_array, Immutable), methods)]))
240240
lam
241241

242242
let rec ignore_cstrs cl =
@@ -358,7 +358,7 @@ let rec build_class_init cla cstr super inh_init cl_init msubst top cl =
358358
(inh_init,
359359
Llet (Strict, inh,
360360
mkappl(oo_prim "inherits", narrow_args @
361-
[lpath; Lconst(Const_pointer ((if top then 1 else 0), Lambda.NAPointer))]),
361+
[lpath; Lconst(Const_pointer ((if top then 1 else 0), Lambda.Pt_na))]),
362362
Llet(StrictOpt, obj_init, lfield inh 0, cl_init)))
363363
| _ ->
364364
let core cl_init =
@@ -503,7 +503,7 @@ let rec builtin_meths self env env2 body =
503503
| Lprim(Parrayrefu _, [Lvar s; Lvar n]) when List.mem s self ->
504504
"var", [Lvar n]
505505
| Lprim(Pfield (n,_), [Lvar e]) when Ident.same e env ->
506-
"env", [Lvar env2; Lconst(Const_pointer (n, Lambda.NAPointer))]
506+
"env", [Lvar env2; Lconst(Const_pointer (n, Lambda.Pt_na))]
507507
| Lsend(Self, met, Lvar s, [], _) when List.mem s self ->
508508
"meth", [met]
509509
| _ -> raise Not_found
@@ -574,7 +574,7 @@ module M = struct
574574
| "send_env" -> SendEnv
575575
| "send_meth" -> SendMeth
576576
| _ -> assert false
577-
in Lconst(Const_pointer(Obj.magic tag, Lambda.NAPointer)) :: args
577+
in Lconst(Const_pointer(Obj.magic tag, Lambda.Pt_na)) :: args
578578
end
579579
open M
580580

bytecomp/translcore.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ and transl_exp0 e =
746746
Matching.for_trywith (Lvar id) (transl_cases_try pat_expr_list))
747747
| Texp_tuple el ->
748748
let ll = transl_list el in
749-
let tag_info = Lambda.Tuple in
749+
let tag_info = Lambda.Blk_tuple in
750750
begin try
751751
Lconst(Const_block(0, tag_info, List.map extract_constant ll))
752752
with Not_constant ->
@@ -756,9 +756,9 @@ and transl_exp0 e =
756756
let ll = transl_list args in
757757
begin match cstr.cstr_tag with
758758
Cstr_constant n ->
759-
Lconst(Const_pointer (n, Lambda.NullConstructor cstr.cstr_name))
759+
Lconst(Const_pointer (n, Lambda.Pt_constructor cstr.cstr_name))
760760
| Cstr_block n ->
761-
let tag_info = (Lambda.Constructor cstr.cstr_name) in
761+
let tag_info = (Lambda.Blk_constructor (cstr.cstr_name, cstr.cstr_nonconsts)) in
762762
begin try
763763
Lconst(Const_block(n,tag_info, List.map extract_constant ll))
764764
with Not_constant ->
@@ -774,10 +774,10 @@ and transl_exp0 e =
774774
| Texp_variant(l, arg) ->
775775
let tag = Btype.hash_variant l in
776776
begin match arg with
777-
None -> Lconst(Const_pointer (tag, Lambda.NullVariant l))
777+
None -> Lconst(Const_pointer (tag, Lambda.Pt_variant l))
778778
| Some arg ->
779779
let lam = transl_exp arg in
780-
let tag_info = Lambda.Variant l in
780+
let tag_info = Lambda.Blk_variant l in
781781
try
782782
Lconst(Const_block(0, tag_info, [Const_base(Const_int tag);
783783
extract_constant lam]))
@@ -811,7 +811,7 @@ and transl_exp0 e =
811811
let master =
812812
match kind with
813813
| Paddrarray | Pintarray ->
814-
Lconst(Const_block(0, Lambda.Array, cl)) (* ATTENTION: ? [|1;2;3;4|]*)
814+
Lconst(Const_block(0, Lambda.Blk_array, cl)) (* ATTENTION: ? [|1;2;3;4|]*)
815815
| Pfloatarray ->
816816
Lconst(Const_float_array(List.map extract_float cl))
817817
| Pgenarray ->
@@ -1116,12 +1116,12 @@ and transl_record all_labels repres lbl_expr_list opt_init_expr =
11161116
if mut = Mutable then raise Not_constant;
11171117
let cl = List.map extract_constant ll in
11181118
match repres with
1119-
Record_regular -> Lconst(Const_block(0, Lambda.Record all_labels_info, cl))
1119+
Record_regular -> Lconst(Const_block(0, Lambda.Blk_record all_labels_info, cl))
11201120
| Record_float ->
11211121
Lconst(Const_float_array(List.map extract_float cl))
11221122
with Not_constant ->
11231123
match repres with
1124-
Record_regular -> Lprim(Pmakeblock(0, Lambda.Record all_labels_info, mut), ll)
1124+
Record_regular -> Lprim(Pmakeblock(0, Lambda.Blk_record all_labels_info, mut), ll)
11251125
| Record_float -> Lprim(Pmakearray Pfloatarray, ll) in
11261126
begin match opt_init_expr with
11271127
None -> lam

bytecomp/translmod.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ let init_shape modl =
203203
Mty_ident _ ->
204204
raise Not_found
205205
| Mty_alias _ ->
206-
Const_block (1, Lambda.default_tag_info, [Const_pointer (0, Lambda.default_pointer_info)])
206+
Const_block (1, Lambda.default_tag_info, [Const_pointer (0, Lambda.Pt_module_alias)])
207207
| Mty_signature sg ->
208208
Const_block(0, Lambda.default_tag_info, [Const_block(0, Lambda.default_tag_info, init_shape_struct env sg)])
209209
| Mty_functor(id, arg, res) ->
@@ -379,7 +379,7 @@ and transl_structure fields cc rootpath = function
379379
Tcoerce_none ->
380380
let fields = List.rev fields in
381381
let field_names = List.map (fun id -> id.Ident.name) fields in
382-
Lprim(Pmakeblock(0, Lambda.Module (Some field_names) , Immutable),
382+
Lprim(Pmakeblock(0, Lambda.Blk_module (Some field_names) , Immutable),
383383
List.fold_right (fun id acc -> begin
384384
(if is_top rootpath then
385385
export_identifiers := id :: !export_identifiers);
@@ -408,7 +408,7 @@ and transl_structure fields cc rootpath = function
408408
end)
409409
pos_cc_list ([], [])in
410410
let lam =
411-
(Lprim(Pmakeblock(0, Module (Some names), Immutable),
411+
(Lprim(Pmakeblock(0, Blk_module (Some names), Immutable),
412412
result))
413413
and id_pos_list =
414414
List.filter (fun (id,_,_) -> not (IdentSet.mem id ids)) id_pos_list

stdlib/target_camlheader

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/Users/hongbozhang/.opam/4.02.3+local-git-master/bin/ocamlrun

stdlib/target_camlheaderd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/Users/hongbozhang/.opam/4.02.3+local-git-master/bin/ocamlrund

0 commit comments

Comments
 (0)