Commits

Anonymous committed 9ee74e5

file path simplified

Comments (0)

Files changed (1)

ocamlspot/ocamlspot.ml

     type id_tree = (Ident.t, Ident.t list) Hashtbl.t 
 
     type file = {
-      path : string option;
+      path : string; (* "" means no source *)
       cwd : string;
       load_paths : string list;
       version : string;
     let dump_file file =
       Format.eprintf "@[<2>{ path= %S;@ cwd= %S;@ load_paths= [ @[%a@] ];@ version= %s;@ argv= [| @[%a@] |]; ... }@]@."
         (match file.path with 
-        | None -> "NONE"
-        | Some s -> s)
+        | "" -> "NONE"
+        | s -> s)
 	file.cwd
         (Format.list "; " (fun ppf s -> Format.fprintf ppf "%S" s)) file.load_paths
         file.version
 	(* fix source_path *)
 	let source_path =
 	  match source_path with
-	  | None -> None
+	  | None -> ""
 	  | Some source_path ->
-	      Some begin
-		if Sys.file_exists source_path then source_path
-		else
-		  try 
-		    let path = find_alternative_source ~spot:path source_path in
-		    Debug.format "Found an alternative source: %s@." path;
-		    path
-		  with
-		  | Not_found -> source_path
-	      end
+	      if Sys.file_exists source_path then source_path
+	      else
+		try 
+		  let path = find_alternative_source ~spot:path source_path in
+		  Debug.format "Found an alternative source: %s@." path;
+		  path
+		with
+		| Not_found -> source_path
 	in
 
         let cwd = 
 	      try
 		let file = load_directly path in
 		begin match file.path with 
-		| Some source -> 
+		| "" -> ()
+		| source -> 
 		    if not (check_time_stamp ~spot:path source) then 
 		      failwith 
 			(Printf.sprintf "Error: source %s is newer than the spot" source)
-		| None -> ()
 		end;
 		Hashtbl.replace cache path file;
 		file
     end
 
     let to_env file = 
-      let env = { Env.path = (match file.path with None -> "" | Some s -> s);
+      let env = { Env.path = file.path;
                   cwd = file.cwd;
 		  load_paths = file.load_paths;
                   structure = Ztree.empty () }
       in
       let str_flat_z = lazy (Eval.structure env file.implementation) in
       lazy (!! (fst (!!str_flat_z))),
-      { Env.path = (match file.path with None -> "" | Some s -> s);
+      { Env.path = file.path;
         cwd = file.cwd;
 	load_paths = file.load_paths;
         structure = lazy (!! (snd (!!str_flat_z)));
       
       let find_local_identifier id =
         (* local identifiers: just consult the table *)
-        let path = match file.path with Some s -> s | None -> "" in
+        let path = file.path in
         let id = { PIdent.path = path; ident = id } in
         id, find_loc id
       in
       assert (Ident.global id);
       let file = Load.load_module ~load_paths id in
       lazy (!!(fst (Eval.structure 
-	{ Env.path = (match file.path with None -> "" | Some s -> s);
+	{ Env.path = file.path;
           cwd = file.cwd;
 	  load_paths = file.load_paths;
           structure = Ztree.empty () } 
       let file = spot_of_file (env.Env.cwd ^/ file) in
       let f = Load.load ~load_paths:[""] file in
       lazy (!!(fst (Eval.structure 
-	      { Env.path = (match f.path with None -> "" | Some s -> s);
+	      { Env.path = f.path;
                 cwd = f.cwd;
 	        load_paths = f.load_paths;
                 structure = Ztree.empty () }