diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2003-12-06 12:39:09 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2003-12-06 12:39:09 +0000 |
commit | 945fa75d5313057eda7dc4976e624d6fc9c7b908 (patch) | |
tree | 83d58d92eaacd7907a62f1b3f5f2bd883c22f6b7 | |
parent | 00a0d9e5b3de802c4c29dcc07ce483ed1c974fc0 (diff) | |
download | ocaml-945fa75d5313057eda7dc4976e624d6fc9c7b908.tar.gz |
must check lets for recursion too
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/newoolab@6007 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | bytecomp/translclass.ml | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/bytecomp/translclass.ml b/bytecomp/translclass.ml index 2cfb15d757..e51ad4fe76 100644 --- a/bytecomp/translclass.ml +++ b/bytecomp/translclass.ml @@ -616,7 +616,7 @@ let transl_class ids cl_id arity pub_meths cl = in assert (inh_init' = []); let table = Ident.create "table" - and class_init = Ident.create "class_init" + and class_init = Ident.create (Ident.name cl_id ^ "_init") and env_init = Ident.create "env_init" and obj_init = Ident.create "obj_init" in let pub_meths = @@ -645,10 +645,9 @@ let transl_class ids cl_id arity pub_meths cl = ids = [] || Typeclass.virtual_methods (Ctype.signature_of_class_type cl.cl_type) = [] and lclass lam = - Llet(Strict, class_init, Lfunction(Curried, [cla], cl_init), - lam class_init) - and lbody class_init = - let fv = free_variables cl_init in + let cl_init = llets (Lfunction(Curried, [cla], cl_init)) in + Llet(Strict, class_init, cl_init, lam (free_variables cl_init)) + and lbody fv = if List.for_all (fun id -> not (IdentSet.mem id fv)) ids then Lapply (oo_prim "make_class",[transl_meth_list pub_meths; Lvar class_init]) @@ -666,7 +665,7 @@ let transl_class ids cl_id arity pub_meths cl = [lambda_unit; Lfunction(Curried,[cla], cl_init); lambda_unit; lenvs]) in (* Still easy: a class defined at toplevel *) - if top && concrete then llets (lclass lbody) else + if top && concrete then lclass lbody else if top then llets (lbody_virt lambda_unit) else (* Now for the hard stuff: prepare for table cacheing *) |