* Re: Dead code removal / cross references
@ 1994-11-11 19:18 Doug Currie, Flavors Technology, Inc.
0 siblings, 0 replies; 3+ messages in thread
From: Doug Currie, Flavors Technology, Inc. @ 1994-11-11 19:18 UTC (permalink / raw)
To: Judicael Courant; +Cc: Pierre.Weis
>called/used ? which modules are used by this one ? is this #open
>really necessary ?) and detect and remove the useless #open and the
>dead code. Does such a tool exists ?
Here is a small piece of what you need...
(* usedmodu.ml *)
(* Copyright ) e, 1994. All rights reserved.
This code may be freely distributed as long as this notice remains.
*)
(* To read a file, and return the list of the modules used *)
let letter_p c =
let x = int_of_char c in
((x > 0x40) & (x < 0x5b)) or ((x > 0x60) & (x < 0x7b))
;;
let identchp c =
let x = int_of_char c in
((x > 0x40) & (x < 0x5b))
or ((x > 0x60) & (x < 0x7b))
or ((x > 0x2f) & (x < 0x3a))
;;
let sm ic =
let buf = create_string 1024 in
let mds = ref [] in
let addm i =
let m = (sub_string buf 0 i) in
if mem m !mds
then ()
else mds := (m :: !mds) in
let
rec s0 () = (* eat whitespace *)
while (*
match input_char ic with
` ` | `\n` | `\r` | `\t` -> true
| c -> set_nth_char buf 0 c; false
*)
let c = input_char ic in
if (letter_p c) or (c = `#`)
then begin set_nth_char buf 0 c; false end
else true
do () done;
s1 1
and s1 i = (* get token *)
match input_char ic with
(*
` ` | `\n` | `\r` | `\t` -> s5 i
| *)
`_` -> begin
match input_char ic with
`_` -> s2 i
| c -> let j = (succ i) in
set_nth_char buf i `_`;
set_nth_char buf j c;
s1 (succ j)
end
| c -> if identchp c
then begin set_nth_char buf i c; s1 (succ i) end
else s5 i
and s2 i = (* record module, eat non-whsp *)
addm i;
while match input_char ic with
` ` | `\n` | `\r` | `\t` -> false
| c -> true
do () done;
s0 ()
and s5 i = (* look for #open *)
if (i = 5) &
((nth_char buf 0) = `#`) &
((nth_char buf 1) = `o`) &
((nth_char buf 2) = `p`) &
((nth_char buf 3) = `e`) &
((nth_char buf 4) = `n`)
then
begin
while (input_char ic) != `"` do () done;
let rec f i =
let c = input_char ic in
if c = `"`
then addm i
else begin set_nth_char buf i c; f (succ i) end in
f 0;
s0 ()
end
else s0 ()
in
try
s0 ()
with End_of_file ->
rev !mds
;;
let modules_used_by_file filename =
let ic = open_in filename in
let res = sm ic in
close_in ic;
res
;;
(* ********************************************* *)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Dead code removal / cross references
1994-11-10 8:11 Judicael Courant
@ 1994-11-14 10:38 ` Xavier Leroy
0 siblings, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 1994-11-14 10:38 UTC (permalink / raw)
To: Judicael Courant; +Cc: caml-list
[-- Attachment #1: Type: text, Size: 1120 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Dead code removal / cross references
@ 1994-11-10 8:11 Judicael Courant
1994-11-14 10:38 ` Xavier Leroy
0 siblings, 1 reply; 3+ messages in thread
From: Judicael Courant @ 1994-11-10 8:11 UTC (permalink / raw)
To: caml-list
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1057 bytes --]
Bonjour,
travaillant sur un projet en camllight assez imposant (plus de 170
fichiers .ml), j'aimerais disposer d'outils permettant d'avoir des
références croisées (ou est définie telle fonction ? ou est appelée
telle fonction ? quels modules sont utilisés par tel module ? ce #open
est-il bien nécessaire ?), et permettant de détecter et d'éliminer lés
#open inutiles et le code mort (relativement a un ou des fichiers
donnés). De tels outils existent-ils ?
Merci.
--------------------------------------
Hello,
working on a quite large project written in camllight (more than 170
.ml files), I would like to have a tool that would generate some
cross-references (where is this function/type defined ? where is it
called/used ? which modules are used by this one ? is this #open
really necessary ?) and detect and remove the useless #open and the
dead code. Does such a tool exists ?
Thanks.
--
Judicaël COURANT tel. : 72 72 85 82
ENSL - LIP email : Judicael.Courant@ens-lyon.fr
46, allée d'Italie
69364 Lyon cedex 07
--
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1994-11-14 10:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-11-11 19:18 Dead code removal / cross references Doug Currie, Flavors Technology, Inc.
-- strict thread matches above, loose matches on Subject: below --
1994-11-10 8:11 Judicael Courant
1994-11-14 10:38 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox