Commit 572d9553 authored by Jérôme Maloberti's avatar Jérôme Maloberti

Applied patch from Stefan Lampe for ocaml stub of constructors with multiple parameters.

parent 6378071b
......@@ -37,6 +37,16 @@ let id s =
(* Printf.eprintf "*** %S\n" s; *)
aux 0
let consId s =
let rec aux i : Ast.ident =
try
let j = String.index_from s i '.' in
<:ident< $uid:String.sub s i (j - i)$.$aux (j+1)$ >>
with Not_found ->
<:ident< $uid:String.sub s i (String.length s - i)$ >>
in
aux 0
let rec typ t =
try IntHash.find memo_typ t.uid
with Not_found ->
......@@ -393,9 +403,17 @@ and to_ml_descr e = function
let vars = mk_vars tl in
let x = mk_var () in
<:match_case< ($str: String.escaped lab$, Some $lid:x$) ->
$matches <:expr< $lid:x$ >>
(* $matches <:expr< $lid:x$ >>
<:expr< $id:id (p ^ lab)$ $tuple_to_ml tl vars$ >>
vars$ >>
vars$ >> *)
$ matches
<:expr< $lid:x$ >> (
List.fold_left
(fun x (t, id) ->
Ast.ExApp(_loc, x, <:expr<$to_ml <:expr< $lid:id$ >> t$>>))
<:expr< $id:consId (p ^ lab)$ >>
(List.combine tl vars))
vars $ >>
) l in
let cases = cases @ [ <:match_case< _ -> assert False >> ] in
pmatch <:expr< Value.get_variant $e$ >> cases
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment