Version française
Home     About     Download     Resources     Contact us    
Browse thread
stl?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] stl?
On Thursday 05 March 2009 09:09:14 Richard Jones wrote:
> On Thu, Mar 05, 2009 at 01:06:34AM +0000, Jon Harrop wrote:
> > Indeed. Which raises the question of how I should put an OCaml front
> > end onto HLVM...
>
> Use the output of camlp4 (the AST).  It's reasonably well documented
> in the camlp4 wiki.

I can parse it easily enough. The type inference and checking is the hard 
part. I'm afraid that OCaml's current implementation might not be very useful 
in that respect anyway if it removes types too soon and makes assumptions 
about the run-time representation.

Perhaps the output of -dlambda would be suitable:

$ cat >a.ml
type t = A of int | B of int | C of int;;
function A n -> n | B n -> 1+n | C n -> 2+n;;
$ ocamlc -dlambda a.ml -o a 2>a.lambda
$ cat a.lambda
(setglobal A!
  (seq
    (function param/72
      (switch* param/72
       case tag 0: (field 0 param/72)
       case tag 1: (+ 1 (field 0 param/72))
       case tag 2: (+ 2 (field 0 param/72))))
    (makeblock 0)))

Is this format documented anywhere?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e