diff options
-rw-r--r-- | MDK/Common/Globals.pm | 61 | ||||
-rw-r--r-- | perl_checker.src/tree.ml | 3 |
2 files changed, 1 insertions, 63 deletions
diff --git a/MDK/Common/Globals.pm b/MDK/Common/Globals.pm deleted file mode 100644 index 0e73b83..0000000 --- a/MDK/Common/Globals.pm +++ /dev/null @@ -1,61 +0,0 @@ -package MDK::Common::Globals; - -=head1 NAME - -Shares constant values between modules - -=head1 SYNOPSIS - - use MDK::Common::Globals "foo", qw($a $b); - - MDK::Common::Globals::init(a => 2, b => 3); - - print $a; # 2 - -=cut - - -sub import { - my (undef, $name, @globals) = @_; - foreach (@globals) { - $name =~ /^\$/ and die qq(usage : use MDK::Common::Globals "group", qw(\$var1 \$var2 ...);\n); - s/^\$// or die qq(bad parameter to "use MDK::Common::Globals": missing variable ``$_'' should be written ``\$$_''); #); - - no strict 'refs'; - my $v = caller() . '::' . $_; - my $lv = "$name __ $_"; - *$v = *$lv; - eval { undef = $$lv; tie $$lv, 'MDK::Common::Globals', $_ }; - } -} - -sub init { - @_ % 2 == 0 or die "usage MDK::Common::Globals::init(key => val, key2 => val2, ...)\n"; - my %l = @_; - foreach (keys %l) { - my $v = caller() . '::' . $_; - no strict 'refs'; - $$v = $l{$_}; - } -} - -sub TIESCALAR { - my ($class, $name) = @_; - my $var; - bless [$var, undef, $name], $class; -} - -sub STORE { - my ($o, $val) = @_; - $o->[1] and die "MDK::Common::Globals::$o->[2] already set\n"; - $o->[1] = 1; - $o->[0] = $val; -} - -sub FETCH { - my ($o) = @_; - $o->[1] or die "MDK::Common::Globals::$o->[2] unset\n"; - $o->[0]; -} - -1; diff --git a/perl_checker.src/tree.ml b/perl_checker.src/tree.ml index a4b5dfb..6008703 100644 --- a/perl_checker.src/tree.ml +++ b/perl_checker.src/tree.ml @@ -176,7 +176,7 @@ let get_exported t = ) empty_exports t let uses_external_package = function - | "vars" | "MDK::Common::Globals" | "Exporter" | "diagnostics" | "strict" | "lib" | "POSIX" | "Gtk" | "Storable" + | "vars" | "Exporter" | "diagnostics" | "strict" | "lib" | "POSIX" | "Gtk" | "Storable" | "Config" | "Socket" | "IO::Socket" | "DynaLoader" | "Data::Dumper" | "Time::localtime" | "Expect" -> true | _ -> false @@ -308,7 +308,6 @@ let get_vars_declaration global_vars_declared file_name package = | My_our("our", ours, pos) -> 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 Access_none, None)) (from_qw ours) | Use(Ident(None, "vars", pos), _) -> |