line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::APL::Compiler; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
103
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
59
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
10
|
use base 'Text::APL::Base'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
822
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _BUILD { |
9
|
19
|
|
|
19
|
|
22
|
my $self = shift; |
10
|
|
|
|
|
|
|
|
11
|
19
|
|
50
|
|
|
127
|
$self->{namespace} ||= 'Text::APL::'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub compile { |
15
|
20
|
|
|
20
|
1
|
66
|
my $self = shift; |
16
|
20
|
|
|
|
|
22
|
my ($code, $context) = @_; |
17
|
|
|
|
|
|
|
|
18
|
20
|
|
|
|
|
36
|
my $template_class = "$self->{namespace}"; |
19
|
|
|
|
|
|
|
|
20
|
20
|
|
100
|
|
|
64
|
$template_class .= '_' . ($context->name || '__anon__') . $context->id; |
21
|
20
|
|
|
|
|
134
|
$template_class =~ s{[^A-Za-z0-9:]}{_}g; |
22
|
|
|
|
|
|
|
|
23
|
20
|
|
|
|
|
45
|
my $package = ''; |
24
|
20
|
|
|
|
|
119
|
$package .= qq/no strict 'refs'; %{"$template_class\::"} = ();/; |
25
|
20
|
|
|
|
|
37
|
$package .= "package $template_class;"; |
26
|
20
|
|
|
|
|
15
|
$package .= 'sub {'; |
27
|
20
|
|
|
|
|
67
|
$package .= 'use strict; use warnings;'; |
28
|
20
|
|
|
|
|
18
|
$package .= 'my $__self = $_[0];'; |
29
|
|
|
|
|
|
|
|
30
|
20
|
|
|
|
|
38
|
$package .= $self->_generate_vars($context); |
31
|
|
|
|
|
|
|
|
32
|
20
|
|
|
|
|
43
|
$package .= $self->_generate_helpers($context); |
33
|
|
|
|
|
|
|
|
34
|
20
|
|
|
|
|
34
|
$package .= $code . '}'; |
35
|
|
|
|
|
|
|
|
36
|
3
|
100
|
|
3
|
|
16
|
eval $package or die $@; |
|
3
|
|
|
3
|
|
3
|
|
|
3
|
|
|
3
|
|
170
|
|
|
3
|
|
|
3
|
|
11
|
|
|
3
|
|
|
1
|
|
3
|
|
|
3
|
|
|
1
|
|
66
|
|
|
3
|
|
|
1
|
|
10
|
|
|
3
|
|
|
1
|
|
3
|
|
|
3
|
|
|
1
|
|
330
|
|
|
3
|
|
|
1
|
|
13
|
|
|
3
|
|
|
1
|
|
5
|
|
|
3
|
|
|
1
|
|
138
|
|
|
3
|
|
|
1
|
|
11
|
|
|
3
|
|
|
1
|
|
4
|
|
|
3
|
|
|
1
|
|
59
|
|
|
3
|
|
|
1
|
|
10
|
|
|
3
|
|
|
1
|
|
6
|
|
|
3
|
|
|
1
|
|
307
|
|
|
20
|
|
|
1
|
|
1207
|
|
|
1
|
|
|
1
|
|
22
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
123
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
110
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1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
|
|
|
43
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
192
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _generate_vars { |
40
|
20
|
|
|
20
|
|
118
|
my $self = shift; |
41
|
20
|
|
|
|
|
24
|
my ($context) = @_; |
42
|
|
|
|
|
|
|
|
43
|
20
|
|
|
|
|
46
|
my $string = ''; |
44
|
20
|
|
|
|
|
59
|
foreach my $var (keys %{$context->vars}) { |
|
20
|
|
|
|
|
39
|
|
45
|
11
|
|
|
|
|
27
|
$string .= qq/my \$$var = \$__self->vars->{$var};/; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
20
|
|
|
|
|
46
|
return $string; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _generate_helpers { |
52
|
20
|
|
|
20
|
|
20
|
my $self = shift; |
53
|
20
|
|
|
|
|
24
|
my ($context) = @_; |
54
|
|
|
|
|
|
|
|
55
|
20
|
|
|
|
|
120
|
my $string = ''; |
56
|
|
|
|
|
|
|
|
57
|
20
|
|
|
|
|
26
|
$string .= "sub var; local *var = sub { \$__self->vars->{\$_[0]} };"; |
58
|
20
|
|
|
|
|
20
|
foreach my $key (keys %{$context->helpers}) { |
|
20
|
|
|
|
|
82
|
|
59
|
40
|
|
|
|
|
85
|
$string .= "sub $key; local *$key = \$__self->helpers->{$key};"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
20
|
|
|
|
|
35
|
return $string; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |