90
90
open Misc
91
91
open Asttypes
92
92
open Types
93
- open Layouts
94
93
open Typedtree
95
94
open Lambda
96
95
open Parmatch
@@ -100,25 +99,25 @@ open Printpat
100
99
module Scoped_location = Debuginfo. Scoped_location
101
100
102
101
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
105
104
106
105
exception Error of Location. t * error
107
106
108
107
let dbg = false
109
108
110
109
(* CR layouts v5: When we're ready to allow non-values, these can be deleted or
111
110
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
114
113
| Ok _ -> ()
115
114
| Error e -> raise (Error (loc, Non_value_layout e))
116
115
117
116
(* CR layouts v5: This function is only used for sanity checking the
118
117
typechecker. When we allow arbitrary layouts in structures, it will have
119
118
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
122
121
| (Value | Immediate | Immediate64 ), _ -> ()
123
122
| Float64 , Record_ufloat -> ()
124
123
| Float64 , (Record_boxed _ | Record_inlined _
@@ -223,7 +222,7 @@ module Half_simple : sig
223
222
type nonrec clause = pattern Non_empty_row .t clause
224
223
225
224
val of_clause :
226
- arg :lambda -> arg_sort :Layouts .sort -> General .clause -> clause
225
+ arg :lambda -> arg_sort :Jkind .sort -> General .clause -> clause
227
226
end = struct
228
227
include Patterns. Half_simple
229
228
@@ -292,7 +291,7 @@ module Simple : sig
292
291
293
292
val explode_or_pat :
294
293
arg :lambda ->
295
- arg_sort :Layouts .sort ->
294
+ arg_sort :Jkind .sort ->
296
295
Half_simple .pattern ->
297
296
mk_action :(vars :Ident .t list -> lambda ) ->
298
297
patbound_action_vars :Ident .t list ->
955
954
956
955
type 'row pattern_matching = {
957
956
mutable cases : 'row list ;
958
- args : (lambda * let_kind * Layouts .sort * layout ) list ;
957
+ args : (lambda * let_kind * Jkind .sort * layout ) list ;
959
958
(* * args are not just Ident.t in at least the following cases:
960
959
- when matching the arguments of a constructor,
961
960
direct field projections are used (make_field_args)
@@ -1695,7 +1694,7 @@ let make_line_matching get_expr_args head def = function
1695
1694
}
1696
1695
1697
1696
type 'a division = {
1698
- args : (lambda * let_kind * Layouts .sort * layout ) list ;
1697
+ args : (lambda * let_kind * Jkind .sort * layout ) list ;
1699
1698
cells : ('a * cell ) list
1700
1699
}
1701
1700
@@ -1782,9 +1781,9 @@ let get_key_constr = function
1782
1781
1783
1782
let get_pat_args_constr p rem =
1784
1783
match p with
1785
- | { pat_desc = Tpat_construct (_ , {cstr_arg_layouts } , args , _ ) } ->
1784
+ | { pat_desc = Tpat_construct (_ , {cstr_arg_jkinds } , args , _ ) } ->
1786
1785
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))
1788
1787
args;
1789
1788
(* CR layouts v5: This sanity check will have to go (or be replaced with a
1790
1789
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 =
1800
1799
let loc = head_loc ~scopes head in
1801
1800
(* CR layouts v5: This sanity check should be removed or changed to
1802
1801
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 ;
1805
1804
let make_field_accesses binding_kind first_pos last_pos argl =
1806
1805
let rec make_args pos =
1807
1806
if pos > last_pos then
1808
1807
argl
1809
1808
else
1810
1809
(Lprim (Pfield (pos, Reads_agree ), [ arg ], loc), binding_kind,
1811
- Sort. for_constructor_arg, layout_field)
1810
+ Jkind. Sort. for_constructor_arg, layout_field)
1812
1811
:: make_args (pos + 1 )
1813
1812
in
1814
1813
make_args first_pos
@@ -1841,7 +1840,7 @@ let get_expr_args_variant_nonconst ~scopes head (arg, _mut, _sort, _layout)
1841
1840
rem =
1842
1841
let loc = head_loc ~scopes head in
1843
1842
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,
1845
1844
layout_field)
1846
1845
:: rem
1847
1846
@@ -2054,7 +2053,7 @@ let inline_lazy_force arg pos loc =
2054
2053
2055
2054
let get_expr_args_lazy ~scopes head (arg , _mut , _sort , _layout ) rem =
2056
2055
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,
2058
2057
layout_lazy_contents) :: rem
2059
2058
2060
2059
let divide_lazy ~scopes head ctx pm =
@@ -2079,7 +2078,7 @@ let get_expr_args_tuple ~scopes head (arg, _mut, _sort, _layout) rem =
2079
2078
rem
2080
2079
else
2081
2080
(Lprim (Pfield (pos, Reads_agree ), [ arg ], loc), Alias ,
2082
- Sort. for_tuple_element, layout_field)
2081
+ Jkind. Sort. for_tuple_element, layout_field)
2083
2082
:: make_args (pos + 1 )
2084
2083
in
2085
2084
make_args 0
@@ -2098,7 +2097,7 @@ let record_matching_line num_fields lbl_pat_list =
2098
2097
List. iter (fun (_ , lbl , pat ) ->
2099
2098
(* CR layouts v5: This void sanity check can be removed when we add proper
2100
2099
void support (or whenever we remove `lbl_pos_void`) *)
2101
- check_record_field_layout lbl;
2100
+ check_record_field_jkind lbl;
2102
2101
patv.(lbl.lbl_pos) < - pat)
2103
2102
lbl_pat_list;
2104
2103
Array. to_list patv
@@ -2125,8 +2124,8 @@ let get_expr_args_record ~scopes head (arg, _mut, sort, layout) rem =
2125
2124
rem
2126
2125
else
2127
2126
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
2130
2129
let lbl_layout = Typeopt. layout_of_sort lbl.lbl_loc lbl_sort in
2131
2130
let sem =
2132
2131
match lbl.lbl_mut with
@@ -2208,7 +2207,7 @@ let get_expr_args_array ~scopes kind head (arg, _mut, _sort, _layout) rem =
2208
2207
(match am with
2209
2208
| Mutable -> StrictOpt
2210
2209
| Immutable -> Alias ),
2211
- Sort. for_array_get_result,
2210
+ Jkind. Sort. for_array_get_result,
2212
2211
layout_field)
2213
2212
:: make_args (pos + 1 )
2214
2213
in
@@ -3665,7 +3664,7 @@ let for_trywith ~scopes ~return_layout loc param pat_act_list =
3665
3664
It is important to *not* include location information in
3666
3665
the reraise (hence the [_noloc]) to avoid seeing this
3667
3666
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
3669
3668
~arg_layout: layout_block ~return_layout loc ~failer: (Reraise_noloc param)
3670
3669
None param pat_act_list Partial
3671
3670
@@ -3780,11 +3779,11 @@ let assign_pat ~scopes body_layout opt nraise catch_ids loc pat pat_sort lam =
3780
3779
match (pat.pat_desc, lam) with
3781
3780
| Tpat_tuple patl , Lprim (Pmakeblock _ , lams , _ ) ->
3782
3781
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
3784
3783
| Tpat_tuple patl , Lconst (Const_block (_ , scl )) ->
3785
3784
opt := true ;
3786
3785
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)
3788
3787
in
3789
3788
List. fold_left2 collect_const acc patl scl
3790
3789
| _ ->
@@ -3852,7 +3851,7 @@ let for_tupled_function ~scopes ~return_layout loc paraml pats_act_list partial
3852
3851
let partial = check_partial_list pats_act_list partial in
3853
3852
(* The arguments of a tupled function are always values since they must be fields *)
3854
3853
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))
3856
3855
paraml
3857
3856
in
3858
3857
let handler =
@@ -3953,12 +3952,12 @@ let do_for_multiple_match ~scopes ~return_layout loc paraml mode pat_act_list pa
3953
3952
let sloc = Scoped_location. of_location ~scopes loc in
3954
3953
Lprim (Pmakeblock (0 , Immutable , None , mode), param_lambda, sloc)
3955
3954
in
3956
- let arg_sort = Sort. for_tuple in
3955
+ let arg_sort = Jkind. Sort. for_tuple in
3957
3956
let handler =
3958
3957
let partial = check_partial pat_act_list partial in
3959
3958
let rows = map_on_rows (fun p -> (p, [] )) pat_act_list in
3960
3959
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
3962
3961
handler (fun partial pm1 ->
3963
3962
let pm1_half =
3964
3963
{ pm1 with
@@ -4022,12 +4021,12 @@ let report_error ppf = function
4022
4021
fprintf ppf
4023
4022
" Non-value detected in translation:@ Please report this error to \
4024
4023
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
4026
4025
| Illegal_record_field c ->
4027
4026
fprintf ppf
4028
4027
" Sort %s detected where value was expected in a record field:@ Please \
4029
4028
report this error to the Jane Street compilers team."
4030
- (Layout . string_of_const c)
4029
+ (Jkind . string_of_const c)
4031
4030
4032
4031
let () =
4033
4032
Location. register_error_of_exn
0 commit comments