diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-01-22 22:17:08 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-01-22 22:17:08 +0000 |
commit | a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1 (patch) | |
tree | 092f44471dd173950facdae7b314db7b81bca883 /perl_checker.src/tree.ml | |
parent | c3b7eb925c11f62803d8cf7e3c8aa1da1ef8ae5b (diff) | |
download | perl_checker-a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1.tar perl_checker-a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1.tar.gz perl_checker-a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1.tar.bz2 perl_checker-a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1.tar.xz perl_checker-a1ce8c538fbfe3fb52aa53c99b09f7f696507cc1.zip |
replace the information "a variable is accessed" with the more precise
Access_none | Access_write_only | Access_various
so that we can say either "variable unused" or "variable assigned but not read"
Diffstat (limited to 'perl_checker.src/tree.ml')
-rw-r--r-- | perl_checker.src/tree.ml | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/perl_checker.src/tree.ml b/perl_checker.src/tree.ml index 23f1467..f452971 100644 --- a/perl_checker.src/tree.ml +++ b/perl_checker.src/tree.ml @@ -20,10 +20,12 @@ type prototype = { proto_nb_max : int option ; } +type variable_used = Access_none | Access_write_only | Access_various + type per_package = { package_name : string ; has_package_name : bool ; - vars_declared : (context * string, pos * bool ref * prototype option) Hashtbl.t; - imported : ((context * string) * (string * bool ref * prototype option)) list option ref; + vars_declared : (context * string, pos * variable_used ref * prototype option) Hashtbl.t; + imported : ((context * string) * (string * variable_used ref * prototype option)) list option ref; exports : exports ; uses : uses ; required_packages : (string * pos) list ; @@ -218,7 +220,7 @@ let read_xs_extension_from_c global_vars_declared file_name package pos = let end_ = String.index_from s offset '"' in let ident = String.sub s offset (end_ - offset) in match split_name_or_fq_name ident with - | None, ident -> Hashtbl.replace package.vars_declared (I_func, ident) (pos, ref false, None) + | None, ident -> Hashtbl.replace package.vars_declared (I_func, ident) (pos, ref Access_none, None) | Some fq, ident -> let fq = package.package_name ^ "::" ^ fq in Hashtbl.replace global_vars_declared (I_func, fq, ident) (pos, None) @@ -292,7 +294,7 @@ let get_proto perl_proto body = let get_vars_declaration global_vars_declared file_name package = List.iter (function | Sub_declaration(Ident(None, name, pos), perl_proto, body, _) -> - Hashtbl.replace package.vars_declared (I_func, name) (pos, ref false, get_proto perl_proto body) + Hashtbl.replace package.vars_declared (I_func, name) (pos, ref Access_none, get_proto perl_proto body) | Sub_declaration(Ident(Some fq, name, pos), perl_proto, body, _) -> Hashtbl.replace global_vars_declared (I_func, fq, name) (pos, get_proto perl_proto body) @@ -300,11 +302,11 @@ let get_vars_declaration global_vars_declared file_name package = | List [ Call_op("=", [My_our("local", ([ I_scalar, "_" ] as ours), pos); _], _) ] | List [ My_our("our", ours, pos) ] | My_our("our", ours, pos) -> - List.iter (fun (context, name) -> Hashtbl.replace package.vars_declared (context, name) (pos, ref false, None)) ours + List.iter (fun (context, name) -> Hashtbl.replace package.vars_declared (context, name) (pos, ref Access_none, None)) ours | Use(Ident(Some "MDK::Common", "Globals", pos), [ String _ ; ours ]) | Use(Ident(None, "vars", pos), [ours]) -> - List.iter (fun (context, name) -> Hashtbl.replace package.vars_declared (context, name) (pos, ref false, None)) (from_qw ours) + List.iter (fun (context, name) -> Hashtbl.replace package.vars_declared (context, name) (pos, ref Access_none, None)) (from_qw ours) | Use(Ident(None, "vars", pos), _) -> die_with_pos pos "usage: use vars qw($var func)" |