Anonymous avatar Anonymous committed 14ee71d

variant+record support (not .mli yet)

Comments (0)

Files changed (10)

   typing/btype.cmo typing/oprint.cmo \
   typing/subst.cmo typing/predef.cmo \
   typing/datarepr.cmo typing/env.cmo \
-  typing/typedtree.cmo typing/spot.cmo typing/ctype.cmo \
+  typing/typedtree.cmo typing/ctype.cmo typing/spot.cmo \
   typing/printtyp.cmo typing/includeclass.cmo \
   typing/mtype.cmo typing/includecore.cmo \
   typing/includemod.cmo typing/parmatch.cmo \

Binary file modified.

ocamlspot/Makefile

   typing/btype typing/oprint \
   typing/subst typing/predef \
   typing/datarepr typing/env \
-  typing/typedtree typing/spot typing/ctype \
+  typing/typedtree typing/ctype typing/spot \
   typing/printtyp typing/includeclass \
   typing/mtype typing/includecore \
   typing/includemod typing/parmatch \

ocamlspot/ocamlspot.ml

       | Type_def id ->
 	  Printf.sprintf "Type_def: %s" 
 	    (Ident.name id)
+      | Constr_use path ->
+	  Printf.sprintf "Constr_use: %s" (Path.name path)
       | Include (_, (Types.Tmty_functor _ | Types.Tmty_ident _)) -> "NOT_IMPLEMENTED"
   end 
 
 	  List.iter (fun (loc, annot) ->
 	    match annot with
 	    | Annot.Value_def id
-	    | Annot.Module_def (id, _) -> Hashtbl.add tbl id loc
+	    | Annot.Module_def (id, _)
+	    | Annot.Type_def id -> Hashtbl.add tbl id loc
 	    | _ -> ()) annots;
 	  tbl
         in
 	    (List.map Spot.Annot.to_string annots));
 	List.iter (function
 	  | Spot.Annot.Value_use path 
+	  | Spot.Annot.Constr_use path 
 	  | Spot.Annot.Module (Spot.Abstraction.Mod_ident path) ->
 	      begin try 
 		  let pident, loc = Spot.File.find_path file path in

ocamlspot/tests/.depend

 test.cmo: 
 test.cmx: 
+test1.cmo: 
+test1.cmx: 
+test10.cmo: 
+test10.cmx: 
+test11.cmo: test10.cmo 
+test11.cmx: test10.cmx 
+test12.cmo: test10.cmo test.cmo 
+test12.cmx: test10.cmx test.cmx 
+test13.cmo: 
+test13.cmx: 
 test3.cmo: 
 test3.cmx: 
+test5.cmo: 
+test5.cmx: 
+test7.cmo: 
+test7.cmx: 
+test8.cmo: test7.cmo 
+test8.cmx: test7.cmx 
+test9.cmo: test7.cmo 
+test9.cmx: test7.cmx 
 dir1/test4.cmo: test.cmo 
 dir1/test4.cmx: test.cmx 
-dir2/test6.cmo: 
-dir2/test6.cmx: 
+dir2/test6.cmo: test5.cmo 
+dir2/test6.cmx: test5.cmx 

ocamlspot/tests/Makefile

 # Requires unix!
 COMPFLAGS= $(INCLUDES_DEP) -I $(OTHERS)/unix
 
-all: test.cmo test1.cmo test2.cmo test3.cmo dir1/test4.cmo test5.cmo dir2/test6.cmo test7.cmo test8.cmo test9.cmo test10.cmo test11.cmo test12.cmo
+all: test.cmo test1.cmo test2.cmo test3.cmo dir1/test4.cmo test5.cmo dir2/test6.cmo test7.cmo test8.cmo test9.cmo test10.cmo test11.cmo test12.cmo test13.cmo
 
 test2.cmo: test.cmo
 	$(OCAMLC) -pack -o $@ $<

ocamlspot/tests/test13.ml

+type t = Foo | Bar of int
+
+let _ = Foo
+let _ = Bar 1
+
+type u = A of v
+and v = B of u | C
+
+let _ = A C
+let _ = B (A C)
+
+type x = { y : int }
+
+let _ = { y = 1 }
+
+
    Annotations are stored in .spot with their locations
 *)
 
-let version = "1.0beta2"
+let version = "1.0beta2p1"
 let magic_number = "OCamlSpot"
 
 module Abstraction = struct
     | Module_def of Ident.t * 'a
     | Include of Types.signature * Types.module_type
     | Type_def of Ident.t
+    | Constr_use of Path.t
 (*
     | Type_scheme of Types.type_expr (* pattern variable's type scheme *)
     | Module_type of Types.module_type (* module's type *)
       | Module_def (id, m) -> 
 	  Module_def (id, Abstraction.abstract_module_expr m)
       | Include (sg, mty) -> Include (sg, mty)
-      | Type_def id -> Type_def id) !recorded
+      | Type_def id -> Type_def id
+      | Constr_use p -> Constr_use p) !recorded
 
 end
 
         (prefix ^ ".spot")
     end
 end
+
+let path_of_constr_type t =
+  match (Ctype.repr t).Types.desc with
+  | Types.Tconstr (p, _, _) -> p
+  | _ -> assert false
     | Module_def of Ident.t * 'a
     | Include of Types.signature * Types.module_type
     | Type_def of Ident.t
+    | Constr_use of Path.t
 (*
     | Type_scheme of Types.type_expr (* pattern variable's type scheme *)
     | Module_type of Types.module_type (* module's type *)
   val dump : source: string option -> string -> unit
   val dump_package : prefix: string -> source: string -> string list -> unit
 end
+
+val path_of_constr_type : Types.type_expr -> Path.t

typing/typecore.ml

           raise(Error(sexp.pexp_loc, Private_type ty));
         (label, {arg with exp_type = instance arg.exp_type}) in
       let lbl_exp_list = type_label_a_list type_label_exp lid_sexp_list in
+      Spot.Annot.record sexp.pexp_loc (Spot.Annot.Constr_use (Spot.path_of_constr_type ty));
       let rec check_duplicates seen_pos lid_sexp lbl_exp =
         match (lid_sexp, lbl_exp) with
           ((lid, _) :: rem1, (lbl, _) :: rem2) ->
       Env.lookup_constructor lid env
     with Not_found ->
       raise(Error(loc, Unbound_constructor lid)) in
+  Spot.Annot.record loc (Spot.Annot.Constr_use (Spot.path_of_constr_type constr.cstr_res));
   let sargs =
     match sarg with
       None -> []
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.