summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/tree.ml
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-01-22 22:17:08 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-01-22 22:17:08 +0000
commit811a65122d8248fbbfce20d638c412443c382faa (patch)
treeb710fcc8c0407f9609005344c3a567c26091b36a /perl_checker.src/tree.ml
parente7e339f26bcf34139293fae6db52fa5c45c09647 (diff)
downloadperl-MDK-Common-811a65122d8248fbbfce20d638c412443c382faa.tar
perl-MDK-Common-811a65122d8248fbbfce20d638c412443c382faa.tar.gz
perl-MDK-Common-811a65122d8248fbbfce20d638c412443c382faa.tar.bz2
perl-MDK-Common-811a65122d8248fbbfce20d638c412443c382faa.tar.xz
perl-MDK-Common-811a65122d8248fbbfce20d638c412443c382faa.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.ml14
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)"