diff options
author | Alain Frisch <alain@frisch.fr> | 2014-03-31 12:20:22 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2014-03-31 12:20:22 +0000 |
commit | 4607a0f8e1dd2615aeff11cad67d5d0b14cace2f (patch) | |
tree | 3e5b21540819a492ef9d30d5a9ab66806b43c014 /toplevel | |
parent | c36fb6d83e80ec95ca39d5446b0a0f9ce484f538 (diff) |
Encode record arguments into extra record declarations.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/constructors_with_record2@14508 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'toplevel')
-rw-r--r-- | toplevel/genprintval.ml | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/toplevel/genprintval.ml b/toplevel/genprintval.ml index 957be155e..58ed61bc3 100644 --- a/toplevel/genprintval.ml +++ b/toplevel/genprintval.ml @@ -248,7 +248,7 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct if O.is_block obj then Cstr_block(O.tag obj) else Cstr_constant(O.obj obj) in - let {cd_id;cd_args;cd_res} = + let {cd_id;cd_args;cd_res;cd_inlined} = Datarepr.find_constr_by_tag tag constr_list in let type_params = match cd_res with @@ -272,7 +272,8 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct Ctype.Cannot_apply -> abstract_type) ty_args in tree_of_constr_with_args (tree_of_constr env path) - (Ident.name cd_id) 0 depth obj ty_args + (Ident.name cd_id) cd_inlined 0 depth obj + ty_args | {type_kind = Type_record(lbl_list, rep)} -> begin match check_depth depth obj ty with Some x -> x @@ -352,9 +353,16 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct tree_list start ty_list and tree_of_constr_with_args - tree_of_cstr cstr_name start depth obj ty_args = + tree_of_cstr cstr_name inlined start depth obj ty_args = let lid = tree_of_cstr cstr_name in - let args = tree_of_val_list start depth obj ty_args in + let args = + if inlined then + match ty_args with + | [ty] -> [ tree_of_val (depth - 1) obj ty ] + | _ -> assert false + else + tree_of_val_list start depth obj ty_args + in Oval_constr (lid, args) and tree_of_exception depth bucket = @@ -383,7 +391,7 @@ module Make(O : OBJ)(EVP : EVALPATH with type valu = O.t) = struct (* TODO? *) in tree_of_constr_with_args - (fun x -> Oide_ident x) name 1 depth bucket ty_args + (fun x -> Oide_ident x) name false 1 depth bucket ty_args with Not_found | EVP.Error -> match check_depth depth bucket ty with Some x -> x |