line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::PassVariables; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
863
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
668
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
###################################################################### |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $seqno = 0; |
8
|
|
|
|
|
|
|
sub prepare { |
9
|
14
|
|
|
14
|
0
|
113
|
my $self = shift; |
10
|
|
|
|
|
|
|
$self->NEXT('prepare', @_, |
11
|
14
|
100
|
|
|
|
74
|
( $self->{package} ? () : ( package => __PACKAGE__ . '::GEN' . $seqno++ ) ) |
12
|
|
|
|
|
|
|
) |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
###################################################################### |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Text elements used for subroutine assembly |
18
|
|
|
|
|
|
|
sub assembler_rules { |
19
|
14
|
|
|
14
|
1
|
104
|
my %rules = ((shift)->NEXT('assembler_rules', @_), |
20
|
|
|
|
|
|
|
eval_start => 'package __PACKAGE__;', |
21
|
|
|
|
|
|
|
no_strict => 'no strict;', |
22
|
|
|
|
|
|
|
init_args => 'local %__PACKAGE__:: = %__PACKAGE__::;' . "\n" . |
23
|
|
|
|
|
|
|
'my %ARGS = @_;' . "\n" . |
24
|
|
|
|
|
|
|
'$m->install_args_hash( "__PACKAGE__", \%ARGS );', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
14
|
|
|
|
|
26
|
$rules{template} = ['$eval_start', '$no_strict', @{$rules{template}}]; |
|
14
|
|
|
|
|
32
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
98
|
return %rules; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub assemble { |
33
|
14
|
|
|
14
|
1
|
15
|
my $self = shift; |
34
|
14
|
|
|
|
|
30
|
my $code = $self->NEXT('assemble', @_); |
35
|
14
|
|
50
|
|
|
30
|
my $package = $self->{package} || 'Text::MicroMason::Commands'; |
36
|
14
|
|
|
|
|
109
|
$code =~ s/(\S)__PACKAGE__/$1$package/g; |
37
|
14
|
|
|
|
|
54
|
$code =~ s/__PACKAGE__(\S)/$package$1/g; |
38
|
14
|
|
|
|
|
31
|
return $code; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
###################################################################### |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# $mason->install_args_hash( $package, $hash_ref ) |
44
|
|
|
|
|
|
|
sub install_args_hash { |
45
|
16
|
|
|
16
|
1
|
1974
|
my ($self, $dest, $hash) = @_; |
46
|
16
|
|
|
|
|
42
|
foreach my $name (keys %$hash) { |
47
|
12
|
|
|
|
|
14
|
my $val = $hash->{$name}; |
48
|
12
|
|
|
|
|
18
|
my $sym = $dest . "::" . $name; |
49
|
3
|
|
|
3
|
|
10
|
no strict 'refs'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
243
|
|
50
|
|
|
|
|
|
|
# This code is cloned from Text::Template |
51
|
12
|
|
|
|
|
8
|
local *SYM = *{$sym}; |
|
12
|
|
|
|
|
39
|
|
52
|
12
|
50
|
|
|
|
30
|
if (! defined $val) { |
|
|
100
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
delete ${"${dest}::"}{$name}; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
} elsif (ref $val) { |
55
|
4
|
|
|
|
|
12
|
*SYM = $val; |
56
|
|
|
|
|
|
|
} else { |
57
|
8
|
|
|
|
|
23
|
*SYM = \$val; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
###################################################################### |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |