diff options
| author | Alain Frisch <alain@frisch.fr> | 2014-04-07 14:53:30 +0000 |
|---|---|---|
| committer | Alain Frisch <alain@frisch.fr> | 2014-04-07 14:53:30 +0000 |
| commit | 1d4e1364bd3dd85b557685e372e7bdba68cf1e21 (patch) | |
| tree | d20096d6369d8dd650212c9a3e1d761ebbb8300b /tools | |
| parent | 73742ea9f32dd026c1cc273e5242df7db8c8d26b (diff) | |
| download | ocaml-1d4e1364bd3dd85b557685e372e7bdba68cf1e21.tar.gz | |
Keep inlined records in Typedtree and Types. Synthesize record types when inserting in the environment and module components, as for labels and constructors. Following features are not supported: inline record for exceptions, GADTs, polymorphic fields.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/constructors_with_record3@14553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/tast_iter.ml | 5 | ||||
| -rw-r--r-- | tools/untypeast.ml | 22 |
2 files changed, 18 insertions, 9 deletions
diff --git a/tools/tast_iter.ml b/tools/tast_iter.ml index c8af136701..2f5f0756f0 100644 --- a/tools/tast_iter.ml +++ b/tools/tast_iter.ml @@ -18,7 +18,10 @@ let structure sub str = List.iter (sub # structure_item) str.str_items let constructor_decl sub cd = - List.iter (sub # core_type) cd.cd_args; + begin match cd.cd_args with + | Cstr_tuple l -> List.iter (sub # core_type) l + | Cstr_record l -> List.iter (fun ld -> sub # core_type ld.ld_type) l + end; opt (sub # core_type) cd.cd_res let structure_item sub x = diff --git a/tools/untypeast.ml b/tools/untypeast.ml index 4d2304e27a..931e8cee58 100644 --- a/tools/untypeast.ml +++ b/tools/untypeast.ml @@ -123,13 +123,7 @@ and untype_type_declaration decl = | Ttype_variant list -> Ptype_variant (List.map untype_constructor_declaration list) | Ttype_record list -> - Ptype_record (List.map (fun ld -> - {pld_name=ld.ld_name; - pld_mutable=ld.ld_mutable; - pld_type=untype_core_type ld.ld_type; - pld_loc=ld.ld_loc; - pld_attributes=ld.ld_attributes} - ) list) + Ptype_record (List.map untype_label_declaration list) ); ptype_private = decl.typ_private; ptype_manifest = option untype_core_type decl.typ_manifest; @@ -137,10 +131,22 @@ and untype_type_declaration decl = ptype_loc = decl.typ_loc; } +and untype_label_declaration ld = + { + pld_name=ld.ld_name; + pld_mutable=ld.ld_mutable; + pld_type=untype_core_type ld.ld_type; + pld_loc=ld.ld_loc; + pld_attributes=ld.ld_attributes; + } + and untype_constructor_declaration cd = { pcd_name = cd.cd_name; - pcd_args = Pcstr_tuple (List.map untype_core_type cd.cd_args); + pcd_args = begin match cd.cd_args with + | Cstr_tuple l -> Pcstr_tuple (List.map untype_core_type l) + | Cstr_record l -> Pcstr_record (List.map untype_label_declaration l) + end; pcd_res = option untype_core_type cd.cd_res; pcd_loc = cd.cd_loc; pcd_attributes = cd.cd_attributes; |
