line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::PassVariables; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
807
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
705
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
###################################################################### |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $seqno = 0; |
8
|
|
|
|
|
|
|
sub prepare { |
9
|
14
|
|
|
14
|
0
|
173
|
my $self = shift; |
10
|
|
|
|
|
|
|
$self->NEXT('prepare', @_, |
11
|
14
|
100
|
|
|
|
98
|
( $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
|
165
|
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
|
|
|
|
|
35
|
$rules{template} = ['$eval_start', '$no_strict', @{$rules{template}}]; |
|
14
|
|
|
|
|
39
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
112
|
return %rules; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub assemble { |
33
|
14
|
|
|
14
|
1
|
23
|
my $self = shift; |
34
|
14
|
|
|
|
|
34
|
my $code = $self->NEXT('assemble', @_); |
35
|
14
|
|
50
|
|
|
38
|
my $package = $self->{package} || 'Text::MicroMason::Commands'; |
36
|
14
|
|
|
|
|
124
|
$code =~ s/(\S)__PACKAGE__/$1$package/g; |
37
|
14
|
|
|
|
|
68
|
$code =~ s/__PACKAGE__(\S)/$package$1/g; |
38
|
14
|
|
|
|
|
36
|
return $code; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
###################################################################### |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# $mason->install_args_hash( $package, $hash_ref ) |
44
|
|
|
|
|
|
|
sub install_args_hash { |
45
|
16
|
|
|
16
|
1
|
2912
|
my ($self, $dest, $hash) = @_; |
46
|
16
|
|
|
|
|
47
|
foreach my $name (keys %$hash) { |
47
|
12
|
|
|
|
|
19
|
my $val = $hash->{$name}; |
48
|
12
|
|
|
|
|
27
|
my $sym = $dest . "::" . $name; |
49
|
3
|
|
|
3
|
|
39
|
no strict 'refs'; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
308
|
|
50
|
|
|
|
|
|
|
# This code is cloned from Text::Template |
51
|
12
|
|
|
|
|
15
|
local *SYM = *{$sym}; |
|
12
|
|
|
|
|
43
|
|
52
|
12
|
50
|
|
|
|
49
|
if (! defined $val) { |
|
|
100
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
delete ${"${dest}::"}{$name}; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
} elsif (ref $val) { |
55
|
4
|
|
|
|
|
16
|
*SYM = $val; |
56
|
|
|
|
|
|
|
} else { |
57
|
8
|
|
|
|
|
22
|
*SYM = \$val; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
###################################################################### |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |