Skip to content

Commit b1962fa

Browse files
authored
flambda-backend: Rename "layout" to "jkind" (#1875)
Change layout --> jkind
1 parent f74b090 commit b1962fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3595
-3560
lines changed

.depend

Lines changed: 60 additions & 0 deletions
Large diffs are not rendered by default.

asmcomp/cmmgen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,13 @@ let join_unboxed_number_kind ~strict k1 k2 =
340340
(* [exttype_of_sort] and [machtype_of_sort] should be kept in sync with
341341
[Typeopt.layout_of_const_sort]. *)
342342
(* CR layouts v5: Void case should probably be typ_void *)
343-
let exttype_of_sort (s : Layouts.Sort.const) =
343+
let exttype_of_sort (s : Jkind.Sort.const) =
344344
match s with
345345
| Value -> XInt
346346
| Float64 -> XFloat
347347
| Void -> Misc.fatal_error "Cmmgen.exttype_of_sort: void encountered"
348348

349-
let machtype_of_sort (s : Layouts.Sort.const) =
349+
let machtype_of_sort (s : Jkind.Sort.const) =
350350
match s with
351351
| Value -> typ_val
352352
| Float64 -> typ_float

boot/menhir/parser.ml

Lines changed: 387 additions & 387 deletions
Large diffs are not rendered by default.

boot/ocamlc

27.5 MB
Binary file not shown.

boot/ocamllex

61 Bytes
Binary file not shown.

debugger/.depend

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ loadprinter.cmo : \
284284
../utils/misc.cmi \
285285
../parsing/longident.cmi \
286286
../utils/load_path.cmi \
287+
../typing/jkind.cmi \
287288
../typing/ident.cmi \
288289
../typing/env.cmi \
289290
../otherlibs/dynlink/dynlink.cmi \
@@ -300,6 +301,7 @@ loadprinter.cmx : \
300301
../utils/misc.cmx \
301302
../parsing/longident.cmx \
302303
../utils/load_path.cmx \
304+
../typing/jkind.cmx \
303305
../typing/ident.cmx \
304306
../typing/env.cmx \
305307
../otherlibs/dynlink/dynlink.cmx \

debugger/loadprinter.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
open Misc
1919
open Longident
2020
open Types
21-
open Layouts
2221

2322
(* Error report *)
2423

@@ -112,7 +111,7 @@ let match_printer_type desc typename =
112111
raise (Error(Unbound_identifier(Ldot(Lident "Topdirs", typename))))
113112
in
114113
Ctype.begin_def();
115-
let ty_arg = Ctype.newvar Layout.(value ~why:Debug_printer_argument) in
114+
let ty_arg = Ctype.newvar Jkind.(value ~why:Debug_printer_argument) in
116115
Ctype.unify (Lazy.force Env.initial_safe_string)
117116
(Ctype.newconstr printer_type [ty_arg])
118117
(Ctype.instance desc.val_type);

lambda/matching.ml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
open Misc
9191
open Asttypes
9292
open Types
93-
open Layouts
9493
open Typedtree
9594
open Lambda
9695
open Parmatch
@@ -100,25 +99,25 @@ open Printpat
10099
module Scoped_location = Debuginfo.Scoped_location
101100

102101
type error =
103-
Non_value_layout of Layout.Violation.t
104-
| Illegal_record_field of Layout.const
102+
Non_value_layout of Jkind.Violation.t
103+
| Illegal_record_field of Jkind.const
105104

106105
exception Error of Location.t * error
107106

108107
let dbg = false
109108

110109
(* CR layouts v5: When we're ready to allow non-values, these can be deleted or
111110
changed to check for void. *)
112-
let layout_must_be_value loc layout =
113-
match Layout.(sub layout (value ~why:V1_safety_check)) with
111+
let jkind_layout_must_be_value loc jkind =
112+
match Jkind.(sub jkind (value ~why:V1_safety_check)) with
114113
| Ok _ -> ()
115114
| Error e -> raise (Error (loc, Non_value_layout e))
116115

117116
(* CR layouts v5: This function is only used for sanity checking the
118117
typechecker. When we allow arbitrary layouts in structures, it will have
119118
outlived its usefulness and should be deleted. *)
120-
let check_record_field_layout lbl =
121-
match Layout.(get_default_value lbl.lbl_layout), lbl.lbl_repres with
119+
let check_record_field_jkind lbl =
120+
match Jkind.(get_default_value lbl.lbl_jkind), lbl.lbl_repres with
122121
| (Value | Immediate | Immediate64), _ -> ()
123122
| Float64, Record_ufloat -> ()
124123
| Float64, (Record_boxed _ | Record_inlined _
@@ -223,7 +222,7 @@ module Half_simple : sig
223222
type nonrec clause = pattern Non_empty_row.t clause
224223

225224
val of_clause :
226-
arg:lambda -> arg_sort:Layouts.sort -> General.clause -> clause
225+
arg:lambda -> arg_sort:Jkind.sort -> General.clause -> clause
227226
end = struct
228227
include Patterns.Half_simple
229228

@@ -292,7 +291,7 @@ module Simple : sig
292291

293292
val explode_or_pat :
294293
arg:lambda ->
295-
arg_sort:Layouts.sort ->
294+
arg_sort:Jkind.sort ->
296295
Half_simple.pattern ->
297296
mk_action:(vars:Ident.t list -> lambda) ->
298297
patbound_action_vars:Ident.t list ->
@@ -955,7 +954,7 @@ end
955954

956955
type 'row pattern_matching = {
957956
mutable cases : 'row list;
958-
args : (lambda * let_kind * Layouts.sort * layout) list;
957+
args : (lambda * let_kind * Jkind.sort * layout) list;
959958
(** args are not just Ident.t in at least the following cases:
960959
- when matching the arguments of a constructor,
961960
direct field projections are used (make_field_args)
@@ -1695,7 +1694,7 @@ let make_line_matching get_expr_args head def = function
16951694
}
16961695

16971696
type 'a division = {
1698-
args : (lambda * let_kind * Layouts.sort * layout) list;
1697+
args : (lambda * let_kind * Jkind.sort * layout) list;
16991698
cells : ('a * cell) list
17001699
}
17011700

@@ -1782,9 +1781,9 @@ let get_key_constr = function
17821781

17831782
let get_pat_args_constr p rem =
17841783
match p with
1785-
| { pat_desc = Tpat_construct (_, {cstr_arg_layouts}, args, _) } ->
1784+
| { pat_desc = Tpat_construct (_, {cstr_arg_jkinds}, args, _) } ->
17861785
List.iteri
1787-
(fun i arg -> layout_must_be_value arg.pat_loc cstr_arg_layouts.(i))
1786+
(fun i arg -> jkind_layout_must_be_value arg.pat_loc cstr_arg_jkinds.(i))
17881787
args;
17891788
(* CR layouts v5: This sanity check will have to go (or be replaced with a
17901789
void-specific check) when we have other non-value sorts *)
@@ -1800,15 +1799,15 @@ let get_expr_args_constr ~scopes head (arg, _mut, sort, layout) rem =
18001799
let loc = head_loc ~scopes head in
18011800
(* CR layouts v5: This sanity check should be removed or changed to
18021801
specifically check for void when we add other non-value sorts. *)
1803-
Array.iter (fun layout -> layout_must_be_value head.pat_loc layout)
1804-
cstr.cstr_arg_layouts;
1802+
Array.iter (fun jkind -> jkind_layout_must_be_value head.pat_loc jkind)
1803+
cstr.cstr_arg_jkinds;
18051804
let make_field_accesses binding_kind first_pos last_pos argl =
18061805
let rec make_args pos =
18071806
if pos > last_pos then
18081807
argl
18091808
else
18101809
(Lprim (Pfield (pos, Reads_agree), [ arg ], loc), binding_kind,
1811-
Sort.for_constructor_arg, layout_field)
1810+
Jkind.Sort.for_constructor_arg, layout_field)
18121811
:: make_args (pos + 1)
18131812
in
18141813
make_args first_pos
@@ -1841,7 +1840,7 @@ let get_expr_args_variant_nonconst ~scopes head (arg, _mut, _sort, _layout)
18411840
rem =
18421841
let loc = head_loc ~scopes head in
18431842
let field_prim = nonconstant_variant_field 1 in
1844-
(Lprim (field_prim, [ arg ], loc), Alias, Sort.for_constructor_arg,
1843+
(Lprim (field_prim, [ arg ], loc), Alias, Jkind.Sort.for_constructor_arg,
18451844
layout_field)
18461845
:: rem
18471846

@@ -2054,7 +2053,7 @@ let inline_lazy_force arg pos loc =
20542053

20552054
let get_expr_args_lazy ~scopes head (arg, _mut, _sort, _layout) rem =
20562055
let loc = head_loc ~scopes head in
2057-
(inline_lazy_force arg Rc_normal loc, Strict, Sort.for_lazy_body,
2056+
(inline_lazy_force arg Rc_normal loc, Strict, Jkind.Sort.for_lazy_body,
20582057
layout_lazy_contents) :: rem
20592058

20602059
let divide_lazy ~scopes head ctx pm =
@@ -2079,7 +2078,7 @@ let get_expr_args_tuple ~scopes head (arg, _mut, _sort, _layout) rem =
20792078
rem
20802079
else
20812080
(Lprim (Pfield (pos, Reads_agree), [ arg ], loc), Alias,
2082-
Sort.for_tuple_element, layout_field)
2081+
Jkind.Sort.for_tuple_element, layout_field)
20832082
:: make_args (pos + 1)
20842083
in
20852084
make_args 0
@@ -2098,7 +2097,7 @@ let record_matching_line num_fields lbl_pat_list =
20982097
List.iter (fun (_, lbl, pat) ->
20992098
(* CR layouts v5: This void sanity check can be removed when we add proper
21002099
void support (or whenever we remove `lbl_pos_void`) *)
2101-
check_record_field_layout lbl;
2100+
check_record_field_jkind lbl;
21022101
patv.(lbl.lbl_pos) <- pat)
21032102
lbl_pat_list;
21042103
Array.to_list patv
@@ -2125,8 +2124,8 @@ let get_expr_args_record ~scopes head (arg, _mut, sort, layout) rem =
21252124
rem
21262125
else
21272126
let lbl = all_labels.(pos) in
2128-
check_record_field_layout lbl;
2129-
let lbl_sort = Layout.sort_of_layout lbl.lbl_layout in
2127+
check_record_field_jkind lbl;
2128+
let lbl_sort = Jkind.sort_of_jkind lbl.lbl_jkind in
21302129
let lbl_layout = Typeopt.layout_of_sort lbl.lbl_loc lbl_sort in
21312130
let sem =
21322131
match lbl.lbl_mut with
@@ -2208,7 +2207,7 @@ let get_expr_args_array ~scopes kind head (arg, _mut, _sort, _layout) rem =
22082207
(match am with
22092208
| Mutable -> StrictOpt
22102209
| Immutable -> Alias),
2211-
Sort.for_array_get_result,
2210+
Jkind.Sort.for_array_get_result,
22122211
layout_field)
22132212
:: make_args (pos + 1)
22142213
in
@@ -3665,7 +3664,7 @@ let for_trywith ~scopes ~return_layout loc param pat_act_list =
36653664
It is important to *not* include location information in
36663665
the reraise (hence the [_noloc]) to avoid seeing this
36673666
silent reraise in exception backtraces. *)
3668-
compile_matching ~scopes ~arg_sort:Sort.for_predef_value
3667+
compile_matching ~scopes ~arg_sort:Jkind.Sort.for_predef_value
36693668
~arg_layout:layout_block ~return_layout loc ~failer:(Reraise_noloc param)
36703669
None param pat_act_list Partial
36713670

@@ -3780,11 +3779,11 @@ let assign_pat ~scopes body_layout opt nraise catch_ids loc pat pat_sort lam =
37803779
match (pat.pat_desc, lam) with
37813780
| Tpat_tuple patl, Lprim (Pmakeblock _, lams, _) ->
37823781
opt := true;
3783-
List.fold_left2 (collect Sort.for_tuple_element) acc patl lams
3782+
List.fold_left2 (collect Jkind.Sort.for_tuple_element) acc patl lams
37843783
| Tpat_tuple patl, Lconst (Const_block (_, scl)) ->
37853784
opt := true;
37863785
let collect_const acc pat sc =
3787-
collect Sort.for_tuple_element acc pat (Lconst sc)
3786+
collect Jkind.Sort.for_tuple_element acc pat (Lconst sc)
37883787
in
37893788
List.fold_left2 collect_const acc patl scl
37903789
| _ ->
@@ -3852,7 +3851,7 @@ let for_tupled_function ~scopes ~return_layout loc paraml pats_act_list partial
38523851
let partial = check_partial_list pats_act_list partial in
38533852
(* The arguments of a tupled function are always values since they must be fields *)
38543853
let args =
3855-
List.map (fun id -> (Lvar id, Strict, Sort.for_tuple_element, layout_field))
3854+
List.map (fun id -> (Lvar id, Strict, Jkind.Sort.for_tuple_element, layout_field))
38563855
paraml
38573856
in
38583857
let handler =
@@ -3953,12 +3952,12 @@ let do_for_multiple_match ~scopes ~return_layout loc paraml mode pat_act_list pa
39533952
let sloc = Scoped_location.of_location ~scopes loc in
39543953
Lprim (Pmakeblock (0, Immutable, None, mode), param_lambda, sloc)
39553954
in
3956-
let arg_sort = Sort.for_tuple in
3955+
let arg_sort = Jkind.Sort.for_tuple in
39573956
let handler =
39583957
let partial = check_partial pat_act_list partial in
39593958
let rows = map_on_rows (fun p -> (p, [])) pat_act_list in
39603959
toplevel_handler ~scopes ~return_layout loc ~failer:Raise_match_failure
3961-
partial [ (arg, Strict, Sort.for_tuple, layout_block) ] rows in
3960+
partial [ (arg, Strict, Jkind.Sort.for_tuple, layout_block) ] rows in
39623961
handler (fun partial pm1 ->
39633962
let pm1_half =
39643963
{ pm1 with
@@ -4022,12 +4021,12 @@ let report_error ppf = function
40224021
fprintf ppf
40234022
"Non-value detected in translation:@ Please report this error to \
40244023
the Jane Street compilers team.@ %a"
4025-
(Layout.Violation.report_with_name ~name:"This expression") err
4024+
(Jkind.Violation.report_with_name ~name:"This expression") err
40264025
| Illegal_record_field c ->
40274026
fprintf ppf
40284027
"Sort %s detected where value was expected in a record field:@ Please \
40294028
report this error to the Jane Street compilers team."
4030-
(Layout.string_of_const c)
4029+
(Jkind.string_of_const c)
40314030

40324031
let () =
40334032
Location.register_error_of_exn

lambda/transl_array_comprehension.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
open Jkind
21
open Lambda
32
open Typedtree
43
open Asttypes
@@ -451,7 +450,7 @@ let iterator ~transl_exp ~scopes ~loc
451450
| Texp_comp_range { ident; pattern = _; start; stop; direction } ->
452451
let bound name value =
453452
Let_binding.make (Immutable Strict) (Pvalue Pintval)
454-
name (transl_exp ~scopes Sort.for_predef_value value)
453+
name (transl_exp ~scopes Jkind.Sort.for_predef_value value)
455454
in
456455
let start = bound "start" start in
457456
let stop = bound "stop" stop in
@@ -468,7 +467,7 @@ let iterator ~transl_exp ~scopes ~loc
468467
| Texp_comp_in { pattern; sequence = iter_arr_exp } ->
469468
let iter_arr =
470469
Let_binding.make (Immutable Strict) (Pvalue Pgenval)
471-
"iter_arr" (transl_exp ~scopes Sort.for_predef_value iter_arr_exp)
470+
"iter_arr" (transl_exp ~scopes Jkind.Sort.for_predef_value iter_arr_exp)
472471
in
473472
let iter_arr_kind = Typeopt.array_kind iter_arr_exp in
474473
let iter_len =
@@ -490,7 +489,7 @@ let iterator ~transl_exp ~scopes ~loc
490489
; for_body =
491490
Matching.for_let
492491
~scopes
493-
~arg_sort:Sort.for_array_element
492+
~arg_sort:Jkind.Sort.for_array_element
494493
~return_layout:(Pvalue Pintval)
495494
pattern.pat_loc
496495
(Lprim(Parrayrefu
@@ -546,7 +545,7 @@ let clause ~transl_exp ~scopes ~loc = function
546545
(Iterator_bindings.all_let_bindings var_bindings)
547546
(make_clause body)
548547
| Texp_comp_when cond ->
549-
fun body -> Lifthenelse(transl_exp ~scopes Sort.for_predef_value cond,
548+
fun body -> Lifthenelse(transl_exp ~scopes Jkind.Sort.for_predef_value cond,
550549
body,
551550
lambda_unit,
552551
(Pvalue Pintval) (* [unit] is immediate *))
@@ -829,7 +828,7 @@ let comprehension
829828
~index
830829
(* CR layouts v4: Ensure that the [transl_exp] here can cope
831830
with non-values. *)
832-
~body:(transl_exp ~scopes Sort.for_array_element comp_body)),
831+
~body:(transl_exp ~scopes Jkind.Sort.for_array_element comp_body)),
833832
(* If it was dynamically grown, cut it down to size *)
834833
match array_sizing with
835834
| Fixed_size -> array.var

lambda/transl_list_comprehension.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
open Jkind
21
open Lambda
32
open Typedtree
43
open Asttypes
@@ -173,7 +172,7 @@ let iterator ~transl_exp ~scopes = function
173172
let transl_bound var bound =
174173
Let_binding.make
175174
(Immutable Strict) (Pvalue Pintval)
176-
var (transl_exp ~scopes Sort.for_predef_value bound)
175+
var (transl_exp ~scopes Jkind.Sort.for_predef_value bound)
177176
in
178177
let start = transl_bound "start" start in
179178
let stop = transl_bound "stop" stop in
@@ -188,7 +187,7 @@ let iterator ~transl_exp ~scopes = function
188187
| Texp_comp_in { pattern; sequence } ->
189188
let iter_list =
190189
Let_binding.make (Immutable Strict) (Pvalue Pgenval)
191-
"iter_list" (transl_exp ~scopes Sort.for_predef_value sequence)
190+
"iter_list" (transl_exp ~scopes Jkind.Sort.for_predef_value sequence)
192191
in
193192
(* Create a fresh variable to use as the function argument *)
194193
let element = Ident.create_local "element" in
@@ -197,11 +196,11 @@ let iterator ~transl_exp ~scopes = function
197196
; element
198197
; element_kind =
199198
Typeopt.layout pattern.pat_env pattern.pat_loc
200-
Sort.for_list_element pattern.pat_type
199+
Jkind.Sort.for_list_element pattern.pat_type
201200
; add_bindings =
202201
(* CR layouts: to change when we allow non-values in sequences *)
203202
Matching.for_let
204-
~scopes ~arg_sort:Sort.for_list_element
203+
~scopes ~arg_sort:Jkind.Sort.for_list_element
205204
~return_layout:(Pvalue Pgenval) pattern.pat_loc (Lvar element)
206205
pattern
207206
}
@@ -298,7 +297,7 @@ let rec translate_clauses
298297
in
299298
Let_binding.let_all arg_lets bindings
300299
| Texp_comp_when cond ->
301-
Lifthenelse(transl_exp ~scopes Sort.for_predef_value cond,
300+
Lifthenelse(transl_exp ~scopes Jkind.Sort.for_predef_value cond,
302301
body ~accumulator,
303302
accumulator,
304303
(Pvalue Pgenval) (* [list]s have the standard representation *))
@@ -313,7 +312,7 @@ let comprehension ~transl_exp ~scopes ~loc { comp_body; comp_clauses } =
313312
rev_list_snoc_local
314313
~loc
315314
~init:accumulator
316-
~last:(transl_exp ~scopes Sort.for_list_element comp_body))
315+
~last:(transl_exp ~scopes Jkind.Sort.for_list_element comp_body))
317316
~accumulator:rev_list_nil
318317
comp_clauses
319318
in

0 commit comments

Comments
 (0)