line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::AllowGlobals; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
649
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
452
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
###################################################################### |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub allow_globals { |
9
|
8
|
|
|
8
|
1
|
19
|
my $self = shift; |
10
|
8
|
|
|
|
|
17
|
my $globals = $self->{allow_globals}; |
11
|
8
|
50
|
|
|
|
33
|
my @current = ref( $globals ) ? @$globals : |
|
|
100
|
|
|
|
|
|
12
|
|
|
|
|
|
|
! defined( $globals ) ? () : |
13
|
|
|
|
|
|
|
split ' ' , $globals; |
14
|
|
|
|
|
|
|
|
15
|
8
|
100
|
|
|
|
26
|
if ( scalar @_ ) { |
16
|
4
|
|
|
|
|
8
|
my %once_each; |
17
|
4
|
|
|
|
|
10
|
@current = grep { ! ( $once_each{$_} ++ ) } @current, @_; |
|
5
|
|
|
|
|
24
|
|
18
|
4
|
|
|
|
|
15
|
$self->{allow_globals} = \@current; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
8
|
50
|
|
|
|
106
|
wantarray ? @current : join(' ', @current); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
###################################################################### |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub set_globals { |
27
|
1
|
|
|
1
|
1
|
6
|
my ( $self, %globals ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
my @globals = keys %globals; |
30
|
1
|
|
|
|
|
4
|
$self->allow_globals( @globals ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $sub = join( "\n", |
33
|
|
|
|
|
|
|
$self->allow_globals_statement(), |
34
|
|
|
|
|
|
|
" sub { ", |
35
|
|
|
|
|
|
|
map( { |
36
|
1
|
|
|
|
|
6
|
my $var = $_; $var =~ s/^[\@\%]/*/; $var =~ s/^(\w)/\$$1/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
37
|
1
|
|
|
|
|
7
|
"$var = \$_[0]{'$_'};" |
38
|
|
|
|
|
|
|
} @globals ), |
39
|
|
|
|
|
|
|
" }" |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
$self->eval_sub( $sub )->( \%globals ) |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
###################################################################### |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub allow_globals_statement { |
48
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
49
|
4
|
|
|
|
|
27
|
"use vars qw(" . $self->allow_globals() . ");" |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub assemble { |
53
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
54
|
3
|
|
|
|
|
10
|
$self->NEXT('assemble', once => $self->allow_globals_statement(), @_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
###################################################################### |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |