@@ -1029,28 +1029,29 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
1029
1029
Location. print_loc (Debuginfo.Scoped_location. to_location loc);
1030
1030
begin match (close env funct, close_list env args) with
1031
1031
((ufunct , Value_closure(_ ,
1032
- ({fun_arity =( Tupled, nparams ) } as fundesc ),
1032
+ ({fun_arity ={ function_kind = Tupled ; params_layout = params_layout ; _} } as fundesc ),
1033
1033
approx_res )),
1034
1034
[Uprim(P. Pmakeblock _ , uargs , _ )])
1035
- when List. length uargs = nparams ->
1035
+ when List. length uargs = List. length params_layout ->
1036
1036
let app =
1037
1037
direct_apply env ~loc ~attribute fundesc ufunct uargs
1038
1038
pos mode ~probe in
1039
1039
(app, strengthen_approx app approx_res)
1040
1040
| ((ufunct, Value_closure (_,
1041
- ({fun_arity= ( Curried _, nparams) } as fundesc),
1041
+ ({fun_arity= {function_kind = Curried _ ; params_layout ; _} } as fundesc),
1042
1042
approx_res)), uargs)
1043
- when nargs = nparams ->
1043
+ when nargs = List. length params_layout ->
1044
1044
let app =
1045
1045
direct_apply env ~loc ~attribute fundesc ufunct uargs
1046
1046
pos mode ~probe in
1047
1047
(app, strengthen_approx app approx_res)
1048
1048
1049
1049
| ((ufunct, (Value_closure (
1050
1050
clos_mode,
1051
- ({fun_arity= ( Curried {nlocal}, nparams) } as fundesc),
1051
+ ({fun_arity= { function_kind = Curried {nlocal} ; params_layout ; _ } } as fundesc),
1052
1052
_) as fapprox)), uargs)
1053
- when nargs < nparams ->
1053
+ when nargs < List. length params_layout ->
1054
+ let nparams = List. length params_layout in
1054
1055
let first_args = List. map (fun arg ->
1055
1056
(V. create_local " arg" , arg) ) uargs in
1056
1057
(* CR mshinwell: Edit when Lapply has kinds *)
@@ -1119,9 +1120,10 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
1119
1120
fail_if_probe ~probe " Partial application" ;
1120
1121
(new_fun, approx)
1121
1122
1122
- | ((ufunct, Value_closure (_, ({fun_arity = ( Curried _, nparams) } as fundesc),
1123
+ | ((ufunct, Value_closure (_, ({fun_arity = { function_kind = Curried _; params_layout ; _} } as fundesc),
1123
1124
_approx_res)), uargs)
1124
- when nargs > nparams ->
1125
+ when nargs > List. length params_layout ->
1126
+ let nparams = List. length params_layout in
1125
1127
let args = List. map (fun arg -> V. create_local " arg" , arg) uargs in
1126
1128
(* CR mshinwell: Edit when Lapply has kinds *)
1127
1129
let kinds =
@@ -1154,6 +1156,7 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
1154
1156
in
1155
1157
let result =
1156
1158
List. fold_left (fun body (id , defining_expr ) ->
1159
+ (* CR ncourant: we need to know the layout of defining_expr here, this is hard *)
1157
1160
Ulet (Immutable , Lambda. layout_top, VP. create id, defining_expr, body))
1158
1161
body
1159
1162
args
@@ -1276,7 +1279,7 @@ let rec close ({ backend; fenv; cenv ; mutable_vars; kinds; catch_env } as env)
1276
1279
in
1277
1280
let arg, _approx = close env arg in
1278
1281
let id = Ident. create_local " dummy" in
1279
- Ulet (Immutable , Lambda. layout_top , VP. create id, arg, cst), approx
1282
+ Ulet (Immutable , Lambda. layout_unit , VP. create id, arg, cst), approx
1280
1283
| Lprim (Pignore, [arg ], _loc ) ->
1281
1284
let expr, approx = make_const_int 0 in
1282
1285
Usequence (fst (close env arg), expr), approx
@@ -1483,10 +1486,9 @@ and close_functions { backend; fenv; cenv; mutable_vars; kinds; catch_env } fun_
1483
1486
|> Symbol. linkage_name
1484
1487
|> Linkage_name. to_string
1485
1488
in
1486
- let arity = List. length params in
1487
1489
let fundesc =
1488
1490
{fun_label = label;
1489
- fun_arity = ( kind, arity) ;
1491
+ fun_arity = { function_kind = kind ; params_layout = List. map snd params ; return_layout = return } ;
1490
1492
fun_closed = initially_closed;
1491
1493
fun_inline = None ;
1492
1494
fun_float_const_prop = ! Clflags. float_const_prop;
@@ -1515,7 +1517,7 @@ and close_functions { backend; fenv; cenv; mutable_vars; kinds; catch_env } fun_
1515
1517
(fun (_id , _params , _return , _body , _mode , _attrib , fundesc , _dbg ) ->
1516
1518
let pos = ! env_pos + 1 in
1517
1519
env_pos := ! env_pos + 1 +
1518
- (match fundesc.fun_arity with ( Curried _ , ( 0 | 1 )) -> 2 | _ -> 3 );
1520
+ (match fundesc.fun_arity with { function_kind = Curried _ ; params_layout = ( [] | [_]); _} -> 2 | _ -> 3 );
1519
1521
pos)
1520
1522
uncurried_defs in
1521
1523
let fv_pos = ! env_pos in
@@ -1565,8 +1567,7 @@ and close_functions { backend; fenv; cenv; mutable_vars; kinds; catch_env } fun_
1565
1567
{
1566
1568
label = fundesc.fun_label;
1567
1569
arity = fundesc.fun_arity;
1568
- params = List. map (fun (var , kind ) -> VP. create var, kind) fun_params;
1569
- return;
1570
+ params = List. map (fun (var , _ ) -> VP. create var) fun_params;
1570
1571
body = ubody;
1571
1572
dbg;
1572
1573
env = Some env_param;
0 commit comments