Commits

camlspotter  committed 6519f79

in 3.12.0 + p4, there are some malformed positions?

  • Participants
  • Parent commits 2935dda
  • Branches custom-3.12.0

Comments (0)

Files changed (5)

File ocamlspot/ocamlspot.ml

   let file f = File.dump_file f
   ;;
 
-  let rannots file = 
+  let rannots_full file = 
     Format.eprintf "@[<2>rannots =@ @[<v>%a@]@]@."
       (Format.list "; " (Regioned.format Annot.format))
       file.File.rannots
   ;;
   
+  let rannots_summary file = 
+    Format.eprintf "@[<2>rannots =@ @[<v>%a@]@]@."
+      (Format.list "; " (Regioned.format Annot.summary))
+      file.File.rannots
+  ;;
+  
   let tree file = Tree.dump !!(file.File.tree)
   ;;
 
     let file = File.load ~load_paths: ["."] path in
     
     if C.dump_file then Dump.file file;
-    if C.dump_rannots then Dump.rannots file;
+    if C.dump_rannots = `Full then Dump.rannots_full file;
+    if C.dump_rannots = `Summary then Dump.rannots_summary file;
     if C.dump_tree then Dump.tree file;
     if C.dump_top then Dump.top file;
     if C.dump_flat then Dump.flat file;

File ocamlspot/spotapi.ml

     | Non_expansive b ->
         Format.fprintf ppf "Non_expansive: %b" b
 
+  let summary ppf = function
+    | Type _typ -> 
+        (* CR jfuruse: not fancy having @. *)
+	Format.fprintf ppf "Type: ...@ ";
+	Format.fprintf ppf "XType: ..."
+    | Mod_type _mty -> 
+	Format.fprintf ppf "Type: ...@ ";
+	Format.fprintf ppf "XType: ..."
+    | Str _str ->
+	Format.fprintf ppf "Str: ..."
+    | Use (use, path) ->
+	Format.fprintf ppf "Use: %s, %s" 
+	  (String.capitalize (Kind.name use)) (Path.name path)
+    | Module _mexp ->
+	Format.fprintf ppf "Module: ..."
+    | Functor_parameter id ->
+	Format.fprintf ppf "Functor_parameter: %s" (Ident.name id)
+    | Non_expansive b ->
+        Format.fprintf ppf "Non_expansive: %b" b
+
   let dummy = Use (Kind.Value, Path.Pident (Ident.create_persistent "dummy"))
 end 
 
     end_ : Position.t
   }
 
-  let of_parsing l =
-    { start = Position.of_lexing_position l.Location.loc_start;
-      end_ = Position.of_lexing_position l.Location.loc_end }
-
   let to_string t =
     Printf.sprintf "%s:%s"
       (Position.to_string t.start)
       (Position.to_string t.end_)
 
+  let of_parsing l =
+    let start = Position.of_lexing_position l.Location.loc_start in
+    let end_ = Position.of_lexing_position l.Location.loc_end in
+    match Position.compare start end_ with
+    | -1 | 0 -> { start = start; end_ = end_ }
+    | _ -> 
+        let pos = { start = start; end_ = end_ } in
+        Format.eprintf "MALFORMED LOCATION %s@." (to_string pos);
+        { start = start; end_ = start }
+
   let compare l1 l2 = 
     if Position.compare l1.start l2.start = 0 
        && Position.compare l2.end_ l1.end_ = 0 then `Same

File ocamlspot/spotapi.mli

   val recorded : unit -> (Location.t * t) list
 
   val format : Format.formatter -> t -> unit
+  val summary : Format.formatter -> t -> unit
+  (** same as [format] but bigger structures are omitted *)    
 
   val dummy : t
 end

File ocamlspot/spotconfig.ml

     
 let rev_anonargs = ref []
 let dump_file = ref false
-let dump_rannots = ref false
+let dump_rannots = ref `None
 let dump_tree = ref false
 let dump_top = ref false
 let dump_flat = ref false
       "--debug", Arg.Set Debug.on, "\t: print debug information";
       "-debug", Arg.Set Debug.on, "\t: (deprecated)";
       "--dump-file", Arg.Set dump_file, "\t: dump spot file"; 
-      "--dump-rannots", Arg.Set dump_rannots, "\t: dump loc-annots";
+      "--dump-rannots", Arg.Unit (fun () -> dump_rannots := `Full), "\t: dump loc-annots";
+      "--dump-rannots-summary", Arg.Unit (fun () -> dump_rannots := `Summary), "\t: dump loc-annots";
       "--dump-tree", Arg.Set dump_tree, "\t: dump annot tree";
       "--dump-top", Arg.Set dump_top, "\t: dump top"; 
       "--dump-flat", Arg.Set dump_flat, "\t: dump flat"; 
 let print_interface = !print_interface
 
 let dump_any = 
-  dump_file || dump_rannots || dump_tree || dump_top || dump_flat
+  dump_file || dump_rannots <> `None || dump_tree || dump_top || dump_flat
 
 module SearchSpec = struct
   type t = 

File ocamlspot/spotconfig_intf.ml

   val print_version : unit -> unit
   
   val dump_file : bool
-  val dump_rannots : bool
+  val dump_rannots : [ `None | `Full | `Summary ]
   val dump_tree : bool
   val dump_top : bool
   val dump_flat : bool