summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/tree.ml
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-11-25 23:02:05 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-11-25 23:02:05 +0000
commitc8343eb58ad633426335e5bb3f1d0d1a89730a46 (patch)
tree3819563b69ffe3dfd88d73435abcaddb4d118a03 /perl_checker.src/tree.ml
parent89de208360b9022db207e1af37bbae992f45002b (diff)
downloadperl_checker-c8343eb58ad633426335e5bb3f1d0d1a89730a46.tar
perl_checker-c8343eb58ad633426335e5bb3f1d0d1a89730a46.tar.gz
perl_checker-c8343eb58ad633426335e5bb3f1d0d1a89730a46.tar.bz2
perl_checker-c8343eb58ad633426335e5bb3f1d0d1a89730a46.tar.xz
perl_checker-c8343eb58ad633426335e5bb3f1d0d1a89730a46.zip
*** empty log message ***
Diffstat (limited to 'perl_checker.src/tree.ml')
-rw-r--r--perl_checker.src/tree.ml34
1 files changed, 22 insertions, 12 deletions
diff --git a/perl_checker.src/tree.ml b/perl_checker.src/tree.ml
index 7353629..69a72fb 100644
--- a/perl_checker.src/tree.ml
+++ b/perl_checker.src/tree.ml
@@ -115,7 +115,7 @@ let get_exported t =
match v with
| List [ List l ] ->
List.map (function
- | Ident(None, tag, _), Ref(I_array, List [List [v]]) ->
+ | Raw_string(tag, _), Ref(I_array, List [List [v]]) ->
let para =
match v with
| Deref(I_array, Ident(None, "EXPORT_OK", _)) -> exports.export_ok
@@ -129,7 +129,7 @@ let get_exported t =
if exports.export_tags <> [] then warn_with_pos pos "weird, %EXPORT_TAGS set twice" ;
{ exports with export_tags = export_tags }
with _ ->
- warn_with_pos pos "unrecognised @EXPORT_TAGS" ;
+ warn_with_pos pos "unrecognised %EXPORT_TAGS" ;
exports)
| List (My_our _ :: _) ->
let _,_ = e,e in
@@ -138,7 +138,8 @@ let get_exported t =
) empty_exports t
let uses_external_package = function
- | "vars" | "Exporter" | "diagnostics" | "strict" | "lib" | "POSIX" | "Config" | "Socket" | "Net::FTP" | "IO::Socket" | "DynaLoader" -> true
+ | "vars" | "MDK::Common::Globals" | "Exporter" | "diagnostics" | "strict" | "lib" | "POSIX"
+ | "Config" | "Socket" | "Net::FTP" | "IO::Socket" | "DynaLoader" -> true
| _ -> false
let get_uses t =
@@ -172,8 +173,11 @@ let get_global_vars_declaration state package =
Hashtbl.add state.global_vars_declared (I_func, some_or fq package.package_name, name) pos
| List [ Call_op("=", [My_our("our", ours, pos); _]) ]
+ | List [ My_our("our", ours, pos) ]
| My_our("our", ours, pos) ->
List.iter (fun (context, name) -> Hashtbl.add state.global_vars_declared (context, package.package_name, name) pos) ours
+
+ | Use(Ident(Some "MDK::Common", "Globals", pos), [ String _ ; ours ])
| Use(Ident(None, "vars", pos), [ours]) ->
List.iter (fun (context, name) -> Hashtbl.add state.global_vars_declared (context, package.package_name, name) pos) (from_qw ours)
| Use(Ident(None, "vars", pos), _) ->
@@ -188,10 +192,12 @@ let get_imports state package =
let exports = package_used.exports in
let imports_vars =
match imports with
- | None ->
- if exports.re_export_all then
- collect (fun (package_name, _) -> (List.assoc package_name state.per_package).exports.export_ok) package_used.uses
- else exports.export_auto
+ | None ->
+ let re =
+ if exports.re_export_all
+ then collect (fun (package_name, _) -> (List.assoc package_name state.per_package).exports.export_ok) package_used.uses
+ else [] in
+ exports.export_auto @ re
| Some l ->
collect (function
| I_raw, tag ->
@@ -205,7 +211,7 @@ let get_imports state package =
die_with_pos pos (sprintf "package %s doesn't export %s" package_name (variable2s variable))
) l
in
- List.map (fun (context, name) -> (context, name), package.package_name) imports_vars
+ List.map (fun (context, name) -> (context, name), package_name) imports_vars
with Not_found -> []
in
collect get_one package.uses
@@ -218,7 +224,6 @@ let rec fold_tree f env e =
| Anonymous_sub(e')
| Ref(_, e')
| Deref(_, e')
- | Package(e')
-> fold_tree f env e'
| Diamond(e')
@@ -232,6 +237,7 @@ let rec fold_tree f env e =
let env = fold_tree f env e2 in
env
+ | Use(_, l)
| List l
| Block l
| Call_op(_, l)
@@ -239,7 +245,6 @@ let rec fold_tree f env e =
| Call(e', l)
| CallP(e', l)
- | Use(e', l)
->
let env = fold_tree f env e' in
List.fold_left (fold_tree f) env l
@@ -282,7 +287,7 @@ let is_global_var context ident =
| _ -> false)
| I_array ->
(match ident with
- | "_" | "ARGV" -> true
+ | "_" | "ARGV" | "INC" -> true
| _ -> false)
| I_hash ->
(match ident with
@@ -290,7 +295,8 @@ let is_global_var context ident =
| _ -> false)
| I_star ->
(match ident with
- | "STDIN" | "STDOUT" | "STDERR" -> true
+ | "STDIN" | "STDOUT" | "STDERR"
+ | "__FILE__" | "__LINE__" | "undef" -> true
| _ -> false)
| I_func ->
(match ident with
@@ -386,6 +392,10 @@ let check_variables vars t =
let vars = check_variables_ vars body in
Some vars
+ | Ident _ as var ->
+ check_variable (I_star, var) vars ;
+ Some vars
+
| My_our(my_or_our, mys, pos) -> Some(declare_My_our vars (my_or_our, mys, pos))
| Deref(context, (Ident _ as var)) ->
check_variable (context, var) vars ;