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