Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed May 2, 2020
1 parent a41e539 commit cef2a23
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
30 changes: 30 additions & 0 deletions src/FindSourceFile.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
open DeadCommon;

let rec interface = items =>
switch (items) {
| [{Typedtree.sig_loc}, ...rest] =>
!Sys.file_exists(sig_loc.loc_start.pos_fname)
? interface(rest) : Some(sig_loc.loc_start.pos_fname)
| [] => None
};
let rec implementation = items =>
switch (items) {
| [{Typedtree.str_loc}, ...rest] =>
!Sys.file_exists(str_loc.loc_start.pos_fname)
? implementation(rest) : Some(str_loc.loc_start.pos_fname)
| [] => None
};
let cmt = cmt_annots =>
switch (cmt_annots) {
| Cmt_format.Interface(signature) =>
if (debug^ && signature.sig_items == []) {
Log_.item("Interface %d@.", signature.sig_items |> List.length);
};
interface(signature.sig_items);
| Implementation(structure) =>
if (debug^ && structure.str_items == []) {
Log_.item("Implementation %d@.", structure.str_items |> List.length);
};
implementation(structure.str_items);
| _ => None
};
31 changes: 0 additions & 31 deletions src/Reanalyze.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,6 @@ open DeadCommon;

let version = Version.version;

module FindSourceFile = {
let rec interface = items =>
switch (items) {
| [{Typedtree.sig_loc}, ...rest] =>
!Sys.file_exists(sig_loc.loc_start.pos_fname)
? interface(rest) : Some(sig_loc.loc_start.pos_fname)
| [] => None
};
let rec implementation = items =>
switch (items) {
| [{Typedtree.str_loc}, ...rest] =>
!Sys.file_exists(str_loc.loc_start.pos_fname)
? implementation(rest) : Some(str_loc.loc_start.pos_fname)
| [] => None
};
let cmt = cmt_annots =>
switch (cmt_annots) {
| Cmt_format.Interface(signature) =>
if (debug^ && signature.sig_items == []) {
Log_.item("Interface %d@.", signature.sig_items |> List.length);
};
interface(signature.sig_items);
| Implementation(structure) =>
if (debug^ && structure.str_items == []) {
Log_.item("Implementation %d@.", structure.str_items |> List.length);
};
implementation(structure.str_items);
| _ => None
};
};

type analysisType =
| Dce
| Exception
Expand Down

0 comments on commit cef2a23

Please sign in to comment.