Anonymous avatar Anonymous committed e8f2e92

functor-parameter not working yet

Comments (0)

Files changed (5)

ocamlspot/ocamlspot.ml

         let flat = 
 	  List.fold_left (fun st (_, annot) -> 
 	    match annot with
-	    | Annot.Str sitem -> sitem :: st
+	    | Annot.Str sitem -> 
+                begin match sitem with
+                | Abstraction.Str_module 
+                    (_, Abstraction.Mod_functor (id, mty, _mexp)) -> 
+                    (* fake a sitem for the functor parameter *)
+                    begin match mty with
+                    | Types.Tmty_ident _ -> assert false (* it is already scraped *)
+                    | Types.Tmty_signature sgitems ->
+                        let sitems = List.map Spot.Abstraction.signature_item sgitems in
+                        Value.Structure ({ PIdent.path = source_path;
+                                           ident = Some id }, sitems) :: sitems  
+                    | Types.Tmty_functor _ (* Ident.t * module_type * module_type *) ->
+                        [] (* not yet done *)
+                    end
+                | _ -> []
+                end @ sitem :: st
 	    | Annot.Type _ 
             | Annot.Use _
 	    | Annot.Module _ 

ocamlspot/tests/Makefile.targets

 external_include.cmo \
 functor.cmo \
 functor_parameter.cmo \
+immediate_include.cmo \
 include_override.cmo \
 included_and_flat.cmo \
 inherit.cmo \

ocamlspot/tests/functor_parameter.ml

-module M = struct
-  type (* M.t => *) t (* <= M.t *)
+module F(A : sig val x : int end) = struct
+  let y = A.x
 end
-
-module F(A : sig 
-  type (* A.t => *) t (* <= A.t *)
-  val x : int 
-  module B : sig
-    type (* B.u => *) u = (t (* A.t *) * M.t (* ? M.t *)) (* <= B.u *)
-    val y : int
-  end
-  module C : sig
-    type v = B.u (* ? B.u *)
-  end
-end) = struct
-  let x = A.x
-  let y = A.B.y
-end
   let cache_module_expr = Module_expr.Table.create 31
   let cache_structure_item = Structure_item.Table.create 31
 
+  let kident_of_sigitem = function
+    | Tsig_value (id, _) -> Kind.Value, id
+    | Tsig_exception (id, _) -> Kind.Exception, id
+    | Tsig_module (id, _, _) ->  Kind.Module, id
+    | Tsig_class (id, _, _) -> Kind.Class, id
+    | Tsig_type (id, _, _) -> Kind.Type, id
+    | Tsig_modtype (id, _) -> Kind.Module_type, id
+    | Tsig_cltype (id, _, _) -> Kind.Class_type, id
+
   let rec module_expr mexp =
     try
       match Module_expr.Table.find cache_module_expr mexp with
 	    structure_item stritem @ st)
 	     str [])
     | Tmod_functor (id, mty, mexp) ->
+        let mty = Mtype.scrape mexp.mod_env mty in
 	Mod_functor(id, mty, module_expr mexp)
     | Tmod_apply (mexp1, mexp2, _mcoercion) -> (* CR jfuruse ? *)
 	Mod_apply (module_expr mexp1, module_expr mexp2)
     | Tstr_include (mexp, _ids, sg) ->
 	let kids =
 	  List.fold_left (fun st sgitem ->
-	    let kind, id =
-	      match sgitem with
-              | Tsig_value (id, {val_kind = Val_reg}) -> Kind.Value, id
-              | Tsig_value (id, _) -> Kind.Value, id
-              | Tsig_exception (id, _) -> Kind.Exception, id
-              | Tsig_module (id, _, _) ->  Kind.Module, id
-              | Tsig_class (id, _, _) -> Kind.Class, id
-	      | Tsig_type (id, _, _) -> Kind.Type, id
-              | Tsig_modtype (id, _) -> Kind.Module_type, id
-              | Tsig_cltype (id, _, _) -> Kind.Class_type, id
-	    in
-	    (kind,id) :: st) [] sg
+	    kident_of_sigitem sgitem :: st) [] sg
 	in
         [Str_include (module_expr mexp, kids)]
 
     | Sig_value of string
     | Sig_module of string
 
+  val kident_of_sigitem : Types.signature_item -> Kind.t * Ident.t
   val module_expr : Typedtree.module_expr -> module_expr
   val structure_item : Typedtree.structure_item -> structure_item list
   val module_type : Types.module_type -> module_expr
   val signature_item : Types.signature_item -> structure_item
+  val functor_parameter : Ident.t -> Types.module_type -> module_expr
 end
 
 module Annot : sig
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.