File tree Expand file tree Collapse file tree 4 files changed +23
-7
lines changed
testsuite/tests/tool-toplevel Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,11 @@ type t =
6868 | Proxy of t
6969;;
7070[%%expect {|
71- type t = Int of int | Str of string | Pair of t * t | Proxy of t
71+ type t =
72+ Int of int [@unboxed]
73+ | Str of string [@unboxed]
74+ | Pair of t * t
75+ | Proxy of t
7276|}];;
7377
7478Int 42 ;;
Original file line number Diff line number Diff line change @@ -502,6 +502,7 @@ let constructor_of_extension_constructor
502502 name = ext.oext_name;
503503 args = ext.oext_args;
504504 return_type = ext.oext_ret_type;
505+ unboxed = false ;
505506 }
506507
507508let split_anon_functor_arguments params =
@@ -712,29 +713,37 @@ and print_out_type_decl kwd ppf td =
712713 print_unboxed
713714
714715and print_out_constr ppf constr =
715- let { name; args = tyl; return_type } = constr in
716+ let { name; args = tyl; return_type; unboxed } = constr in
716717 let name =
717718 match name with
718719 | "::" -> " (::)" (* #7200 *)
719720 | s -> s
720721 in
722+ let pp_unboxed ppf = function
723+ | false -> ()
724+ | true -> fprintf ppf " @ [@unboxed]"
725+ in
721726 match return_type with
722727 | None ->
723728 begin match tyl with
724729 | [] ->
725730 pp_print_string ppf name
726731 | _ ->
727- fprintf ppf " @[<2>%s of@ %a@]" name
732+ fprintf ppf " @[<2>%s of@ %a%a @]" name
728733 (print_typlist print_simple_out_type " *" ) tyl
734+ pp_unboxed unboxed
729735 end
730736 | Some ret_type ->
731737 begin match tyl with
732738 | [] ->
733- fprintf ppf " @[<2>%s :@ %a@]" name print_simple_out_type ret_type
739+ fprintf ppf " @[<2>%s :@ %a%a@]" name
740+ print_simple_out_type ret_type
741+ pp_unboxed unboxed
734742 | _ ->
735- fprintf ppf " @[<2>%s :@ %a -> %a@]" name
743+ fprintf ppf " @[<2>%s :@ %a -> %a%a @]" name
736744 (print_typlist print_simple_out_type " *" )
737745 tyl print_simple_out_type ret_type
746+ pp_unboxed unboxed
738747 end
739748
740749and print_out_extension_constructor ppf ext =
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ and out_constructor = {
8282 name : string ;
8383 args : out_type list ;
8484 return_type : out_type option ;
85+ unboxed : bool ;
8586}
8687
8788and out_variant =
Original file line number Diff line number Diff line change @@ -1420,13 +1420,14 @@ and tree_of_constructor_arguments = function
14201420and tree_of_constructor cd =
14211421 let name = Ident. name cd.cd_id in
14221422 let arg () = tree_of_constructor_arguments cd.cd_args in
1423+ let unboxed = Builtin_attributes. has_unboxed cd.cd_attributes in
14231424 match cd.cd_res with
1424- | None -> { name; args = arg () ; return_type = None }
1425+ | None -> { name; args = arg () ; return_type = None ; unboxed; }
14251426 | Some res ->
14261427 Names. with_local_names (fun () ->
14271428 let ret = tree_of_typexp Type res in
14281429 let args = arg () in
1429- { name; args; return_type = Some ret })
1430+ { name; args; return_type = Some ret; unboxed; })
14301431
14311432and tree_of_label l =
14321433 (Ident. name l.ld_id, l.ld_mutable = Mutable , tree_of_typexp Type l.ld_type)
@@ -1516,6 +1517,7 @@ let extension_only_constructor id ppf ext =
15161517 name;
15171518 args;
15181519 return_type = ret;
1520+ unboxed = false ;
15191521 } : out_constructor)
15201522
15211523(* Print a value declaration *)
You can’t perform that action at this time.
0 commit comments