File tree Expand file tree Collapse file tree 4 files changed +23
-4
lines changed
testsuite/tests/tool-toplevel Expand file tree Collapse file tree 4 files changed +23
-4
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 ocstr_name = ext.oext_name;
503503 ocstr_args = ext.oext_args;
504504 ocstr_return_type = ext.oext_ret_type;
505+ ocstr_unboxed = false ;
505506 }
506507
507508let split_anon_functor_arguments params =
@@ -716,29 +717,38 @@ and print_out_constr ppf constr =
716717 ocstr_name = name;
717718 ocstr_args = tyl;
718719 ocstr_return_type = return_type;
720+ ocstr_unboxed = unboxed;
719721 } = constr in
720722 let name =
721723 match name with
722724 | "::" -> " (::)" (* #7200 *)
723725 | s -> s
724726 in
727+ let pp_unboxed ppf = function
728+ | false -> ()
729+ | true -> fprintf ppf " @ [@unboxed]"
730+ in
725731 match return_type with
726732 | None ->
727733 begin match tyl with
728734 | [] ->
729735 pp_print_string ppf name
730736 | _ ->
731- fprintf ppf " @[<2>%s of@ %a@]" name
737+ fprintf ppf " @[<2>%s of@ %a%a @]" name
732738 (print_typlist print_simple_out_type " *" ) tyl
739+ pp_unboxed unboxed
733740 end
734741 | Some ret_type ->
735742 begin match tyl with
736743 | [] ->
737- fprintf ppf " @[<2>%s :@ %a@]" name print_simple_out_type ret_type
744+ fprintf ppf " @[<2>%s :@ %a%a@]" name
745+ print_simple_out_type ret_type
746+ pp_unboxed unboxed
738747 | _ ->
739- fprintf ppf " @[<2>%s :@ %a -> %a@]" name
748+ fprintf ppf " @[<2>%s :@ %a -> %a%a @]" name
740749 (print_typlist print_simple_out_type " *" )
741750 tyl print_simple_out_type ret_type
751+ pp_unboxed unboxed
742752 end
743753
744754and print_out_extension_constructor ppf ext =
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ and out_constructor = {
8282 ocstr_name : string ;
8383 ocstr_args : out_type list ;
8484 ocstr_return_type : out_type option ;
85+ ocstr_unboxed : bool ;
8586}
8687
8788and out_variant =
Original file line number Diff line number Diff line change @@ -1420,11 +1420,13 @@ 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
14241425 | None -> {
14251426 ocstr_name = name;
14261427 ocstr_args = arg () ;
14271428 ocstr_return_type = None ;
1429+ ocstr_unboxed = unboxed;
14281430 }
14291431 | Some res ->
14301432 Names. with_local_names (fun () ->
@@ -1434,6 +1436,7 @@ and tree_of_constructor cd =
14341436 ocstr_name = name;
14351437 ocstr_args = args;
14361438 ocstr_return_type = Some ret;
1439+ ocstr_unboxed = unboxed;
14371440 })
14381441
14391442and tree_of_label l =
@@ -1523,6 +1526,7 @@ let extension_only_constructor id ppf ext =
15231526 ocstr_name = name;
15241527 ocstr_args = args;
15251528 ocstr_return_type = ret;
1529+ ocstr_unboxed = false ;
15261530 }
15271531
15281532(* Print a value declaration *)
You can’t perform that action at this time.
0 commit comments