diff options
author | Nicolas Pouillard <np@nicolaspouillard.fr> | 2006-12-09 13:49:10 +0000 |
---|---|---|
committer | Nicolas Pouillard <np@nicolaspouillard.fr> | 2006-12-09 13:49:10 +0000 |
commit | 87919802b8b798f4fab307aa0442568678974b52 (patch) | |
tree | 0f77c353cd5660e6409231b8f9e323da1c106c43 /debugger/source.ml | |
parent | 86645badd646e5df9128e566ca79117e4e387126 (diff) | |
download | ocaml-87919802b8b798f4fab307aa0442568678974b52.tar.gz |
Pass a Lexing.position value to make source_of_module, get_buffer and show
listing more accurate.
Also move the yes_or_no function to it's own module Question to avoid a
module dependency cycle, since Lexer use Parser types and Parser
implementation use Input_handling that defined yes_or_no that use Lexer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7767 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'debugger/source.ml')
-rw-r--r-- | debugger/source.ml | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/debugger/source.ml b/debugger/source.ml index f937c782a0..f1519b438a 100644 --- a/debugger/source.ml +++ b/debugger/source.ml @@ -18,10 +18,24 @@ open Misc open Primitives +let source_extensions = [".ml"] + (*** Conversion function. ***) -let source_of_module mdle = - find_in_path_uncap !Config.load_path (mdle ^ ".ml") +let source_of_module pos mdle = + let fname = pos.Lexing.pos_fname in + if fname = "" then + let rec loop = + function + | [] -> raise Not_found + | ext :: exts -> + try find_in_path_uncap !Config.load_path (mdle ^ ext) + with Not_found -> loop exts + in loop source_extensions + else if Filename.is_implicit fname then + find_in_path !Config.load_path fname + else + fname (*** Buffer cache ***) @@ -38,10 +52,10 @@ let buffer_list = let flush_buffer_list () = buffer_list := [] -let get_buffer mdle = +let get_buffer pos mdle = try List.assoc mdle !buffer_list with Not_found -> - let inchan = open_in_bin (source_of_module mdle) in + let inchan = open_in_bin (source_of_module pos mdle) in let (content, _) as buffer = (String.create (in_channel_length inchan), ref []) in |