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