line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl6::Pod::Utl::Context; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
72
|
|
5
|
3
|
|
|
3
|
|
1785
|
use Perl6::Pod::Directive::use; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
77
|
|
6
|
3
|
|
|
3
|
|
1623
|
use Perl6::Pod::Directive::config; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
75
|
|
7
|
3
|
|
|
3
|
|
1688
|
use Perl6::Pod::Directive::alias; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
79
|
|
8
|
3
|
|
|
3
|
|
1658
|
use Perl6::Pod::Block::comment; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
76
|
|
9
|
3
|
|
|
3
|
|
1650
|
use Perl6::Pod::Block::code; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
103
|
|
10
|
3
|
|
|
3
|
|
1817
|
use Perl6::Pod::Block::para; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
78
|
|
11
|
3
|
|
|
3
|
|
1573
|
use Perl6::Pod::Block::head; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
77
|
|
12
|
3
|
|
|
3
|
|
1821
|
use Perl6::Pod::Block::table; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
101
|
|
13
|
3
|
|
|
3
|
|
1660
|
use Perl6::Pod::Block::output; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
73
|
|
14
|
3
|
|
|
3
|
|
1626
|
use Perl6::Pod::Block::input; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
128
|
|
15
|
3
|
|
|
3
|
|
1635
|
use Perl6::Pod::Block::nested; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
105
|
|
16
|
3
|
|
|
3
|
|
1953
|
use Perl6::Pod::Block::item; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
80
|
|
17
|
3
|
|
|
3
|
|
1851
|
use Perl6::Pod::FormattingCode::A; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
79
|
|
18
|
3
|
|
|
3
|
|
1808
|
use Perl6::Pod::FormattingCode::C; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
84
|
|
19
|
3
|
|
|
3
|
|
1592
|
use Perl6::Pod::FormattingCode::D; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
79
|
|
20
|
3
|
|
|
3
|
|
1714
|
use Perl6::Pod::FormattingCode::K; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
84
|
|
21
|
3
|
|
|
3
|
|
1669
|
use Perl6::Pod::FormattingCode::M; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
77
|
|
22
|
3
|
|
|
3
|
|
1762
|
use Perl6::Pod::FormattingCode::L; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
88
|
|
23
|
|
|
|
|
|
|
#use Perl6::Pod::FormattingCode::P; |
24
|
3
|
|
|
3
|
|
1563
|
use Perl6::Pod::FormattingCode::B; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
77
|
|
25
|
3
|
|
|
3
|
|
1702
|
use Perl6::Pod::FormattingCode::I; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
80
|
|
26
|
3
|
|
|
3
|
|
1638
|
use Perl6::Pod::FormattingCode::S; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
95
|
|
27
|
3
|
|
|
3
|
|
1642
|
use Perl6::Pod::FormattingCode::U; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
79
|
|
28
|
3
|
|
|
3
|
|
1698
|
use Perl6::Pod::FormattingCode::X; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
114
|
|
29
|
3
|
|
|
3
|
|
1700
|
use Perl6::Pod::FormattingCode::E; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
122
|
|
30
|
3
|
|
|
3
|
|
1909
|
use Perl6::Pod::FormattingCode::R; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
85
|
|
31
|
3
|
|
|
3
|
|
1633
|
use Perl6::Pod::FormattingCode::T; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
80
|
|
32
|
3
|
|
|
3
|
|
1580
|
use Perl6::Pod::FormattingCode::N; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
88
|
|
33
|
3
|
|
|
3
|
|
1568
|
use Perl6::Pod::FormattingCode::Z; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
106
|
|
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
2021
|
use Tie::UnionHash; |
|
3
|
|
|
|
|
8130
|
|
|
3
|
|
|
|
|
83
|
|
36
|
3
|
|
|
3
|
|
17
|
use Data::Dumper; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
392
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
use => 'Perl6::Pod::Directive::use', |
39
|
|
|
|
|
|
|
comment => 'Perl6::Pod::Block::comment', |
40
|
|
|
|
|
|
|
'M<>' => 'Perl6::Pod::FormattingCode::M', |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# 'P<>' => 'Perl6::Pod::FormattingCode::P', |
43
|
|
|
|
|
|
|
'S<>' => 'Perl6::Pod::FormattingCode::S', |
44
|
|
|
|
|
|
|
'V<>' => 'Perl6::Pod::FormattingCode::C', #V like C |
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use constant { |
48
|
3
|
|
|
|
|
1995
|
DEFAULT_USE => { |
49
|
|
|
|
|
|
|
'File' => '-', |
50
|
|
|
|
|
|
|
'config'=>'Perl6::Pod::Directive::config', |
51
|
|
|
|
|
|
|
code => 'Perl6::Pod::Block::code', |
52
|
|
|
|
|
|
|
'para' => 'Perl6::Pod::Block::para', |
53
|
|
|
|
|
|
|
alias => 'Perl6::Pod::Directive::alias', |
54
|
|
|
|
|
|
|
nested => 'Perl6::Pod::Block::nested', |
55
|
|
|
|
|
|
|
output => 'Perl6::Pod::Block::output', |
56
|
|
|
|
|
|
|
input => 'Perl6::Pod::Block::input', |
57
|
|
|
|
|
|
|
item => 'Perl6::Pod::Block::item', |
58
|
|
|
|
|
|
|
defn => 'Perl6::Pod::Block::item', |
59
|
|
|
|
|
|
|
head => 'Perl6::Pod::Block::head', |
60
|
|
|
|
|
|
|
table => 'Perl6::Pod::Block::table', |
61
|
|
|
|
|
|
|
'A<>' => 'Perl6::Pod::FormattingCode::A', |
62
|
|
|
|
|
|
|
'B<>' => 'Perl6::Pod::FormattingCode::B', |
63
|
|
|
|
|
|
|
'C<>' => 'Perl6::Pod::FormattingCode::C', |
64
|
|
|
|
|
|
|
'D<>' => 'Perl6::Pod::FormattingCode::D', |
65
|
|
|
|
|
|
|
'E<>' => 'Perl6::Pod::FormattingCode::E', |
66
|
|
|
|
|
|
|
'I<>' => 'Perl6::Pod::FormattingCode::I', |
67
|
|
|
|
|
|
|
'K<>' => 'Perl6::Pod::FormattingCode::K', |
68
|
|
|
|
|
|
|
'L<>' => 'Perl6::Pod::FormattingCode::L', |
69
|
|
|
|
|
|
|
'N<>' => 'Perl6::Pod::FormattingCode::N', |
70
|
|
|
|
|
|
|
'R<>' => 'Perl6::Pod::FormattingCode::R', |
71
|
|
|
|
|
|
|
'T<>' => 'Perl6::Pod::FormattingCode::T', |
72
|
|
|
|
|
|
|
'U<>' => 'Perl6::Pod::FormattingCode::U', |
73
|
|
|
|
|
|
|
'V<>' => 'Perl6::Pod::FormattingCode::C', |
74
|
|
|
|
|
|
|
'X<>' => 'Perl6::Pod::FormattingCode::X', |
75
|
|
|
|
|
|
|
'Z<>' => 'Perl6::Pod::FormattingCode::Z', |
76
|
|
|
|
|
|
|
'*' => 'Perl6::Pod::Block', |
77
|
|
|
|
|
|
|
'*<>' => 'Perl6::Pod::FormattingCode', |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# use => 'Perl6::Pod::Directive::use', |
80
|
|
|
|
|
|
|
# config => 'Perl6::Pod::Directive::config', |
81
|
|
|
|
|
|
|
# comment => 'Perl6::Pod::Block::comment', |
82
|
|
|
|
|
|
|
# alias => 'Perl6::Pod::Directive::alias', |
83
|
|
|
|
|
|
|
# code => 'Perl6::Pod::Block::code', |
84
|
|
|
|
|
|
|
# para => 'Perl6::Pod::Block::para', |
85
|
|
|
|
|
|
|
# table => 'Perl6::Pod::Block::table', |
86
|
|
|
|
|
|
|
# output => 'Perl6::Pod::Block::output', |
87
|
|
|
|
|
|
|
# input => 'Perl6::Pod::Block::input', |
88
|
|
|
|
|
|
|
# nested => 'Perl6::Pod::Block::nested', |
89
|
|
|
|
|
|
|
# item => 'Perl6::Pod::Block::item', |
90
|
|
|
|
|
|
|
# defn => 'Perl6::Pod::Block::item', |
91
|
|
|
|
|
|
|
# 'C<>' => 'Perl6::Pod::FormattingCode::C', |
92
|
|
|
|
|
|
|
# 'D<>' => 'Perl6::Pod::FormattingCode::D', |
93
|
|
|
|
|
|
|
# 'K<>' => 'Perl6::Pod::FormattingCode::K', |
94
|
|
|
|
|
|
|
# 'M<>' => 'Perl6::Pod::FormattingCode::M', |
95
|
|
|
|
|
|
|
# 'L<>' => 'Perl6::Pod::FormattingCode::L', |
96
|
|
|
|
|
|
|
# 'B<>' => 'Perl6::Pod::FormattingCode::B', |
97
|
|
|
|
|
|
|
# 'I<>' => 'Perl6::Pod::FormattingCode::I', |
98
|
|
|
|
|
|
|
# 'X<>' => 'Perl6::Pod::FormattingCode::X', |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# 'P<>' => 'Perl6::Pod::FormattingCode::P', |
101
|
|
|
|
|
|
|
# 'U<>' => 'Perl6::Pod::FormattingCode::U', |
102
|
|
|
|
|
|
|
# 'E<>' => 'Perl6::Pod::FormattingCode::E', |
103
|
|
|
|
|
|
|
# 'N<>' => 'Perl6::Pod::FormattingCode::N', |
104
|
|
|
|
|
|
|
# 'A<>' => 'Perl6::Pod::FormattingCode::A', |
105
|
|
|
|
|
|
|
# 'R<>' => 'Perl6::Pod::FormattingCode::R', |
106
|
|
|
|
|
|
|
# 'S<>' => 'Perl6::Pod::FormattingCode::S', |
107
|
|
|
|
|
|
|
# 'T<>' => 'Perl6::Pod::FormattingCode::T', |
108
|
|
|
|
|
|
|
# 'V<>' => 'Perl6::Pod::FormattingCode::C', #V like C |
109
|
|
|
|
|
|
|
# 'Z<>' => 'Perl6::Pod::FormattingCode::Z', |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
112
|
3
|
|
|
3
|
|
17
|
}; |
|
3
|
|
|
|
|
5
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 new [ ] |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub new { |
119
|
2
|
|
|
2
|
1
|
3
|
my $class = shift; |
120
|
2
|
50
|
|
|
|
7
|
$class = ref $class if ref $class; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#set default contexts |
123
|
2
|
|
|
|
|
21
|
my %args = ( |
124
|
|
|
|
|
|
|
_usef => {}, |
125
|
|
|
|
|
|
|
_alias => {}, |
126
|
|
|
|
|
|
|
_use => DEFAULT_USE, |
127
|
|
|
|
|
|
|
_config => {}, |
128
|
|
|
|
|
|
|
_encoding => 'UTF-8', |
129
|
|
|
|
|
|
|
_custom => {}, |
130
|
|
|
|
|
|
|
_class_opts => {}, |
131
|
|
|
|
|
|
|
_allow_context => {}, |
132
|
|
|
|
|
|
|
@_ |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#create union hashes |
136
|
2
|
|
|
|
|
12
|
while ( my ( $key, $val ) = each %args ) { |
137
|
16
|
100
|
66
|
|
|
55
|
next unless ( ref($val) || ref($val) eq 'HASH' ); |
138
|
14
|
|
|
|
|
21
|
my %new_map = (); |
139
|
14
|
|
|
|
|
57
|
tie %new_map, 'Tie::UnionHash', $val, {}; |
140
|
14
|
|
|
|
|
533
|
$args{$key} = \%new_map; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
143
|
2
|
|
|
|
|
5
|
my $self = bless( \%args, $class ); |
144
|
2
|
|
|
|
|
9
|
return $self; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 sub_context |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
create sub_context |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub sub_context { |
154
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
155
|
0
|
|
|
|
|
0
|
return __PACKAGE__->new(%$self); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 get_config block_name |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Get options for B in current context |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$context->get_config('item1'); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return ref to config options for ะก |
165
|
|
|
|
|
|
|
( implement :like attr) |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub get_config { |
170
|
|
|
|
|
|
|
#TODO check for infinity loop |
171
|
9
|
|
|
9
|
1
|
11
|
my $self = shift; |
172
|
9
|
|
50
|
|
|
23
|
my $class_name = shift || return {}; |
173
|
9
|
100
|
|
|
|
11
|
my %class_config = %{ $self->config->{$class_name} || {} }; |
|
9
|
|
|
|
|
21
|
|
174
|
9
|
100
|
|
|
|
256
|
if ( my $like = delete $class_config{like} ) { |
175
|
2
|
50
|
|
|
|
11
|
my @likes = ref($like) eq 'ARRAY' ? @$like : ($like); |
176
|
2
|
|
|
|
|
3
|
foreach my $lname (@likes) { |
177
|
2
|
|
|
|
|
5
|
%class_config =( %class_config, %{ $self->get_config($lname) } ); |
|
2
|
|
|
|
|
9
|
|
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
9
|
|
|
|
|
36
|
\%class_config; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 config |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
return ref to hash of pod options per blockname |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub config { |
190
|
12
|
|
|
12
|
1
|
52
|
return $_[0]->{_config}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 usef |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
return ref to hash of plugin per formatcode name |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub usef { |
200
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{_usef}; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 use |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
return ref to hash of perl module per blockname |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub use { |
210
|
5
|
|
|
5
|
1
|
14
|
return $_[0]->{_use}; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 custom |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
return ref to hash of user defined keys,vals |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub custom { |
220
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_custom}; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 class_opts |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
return ref to hash of Class optioons to create loaded by use mods |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub class_opts { |
230
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_class_opts}; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 set_use , ':config_options' |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub set_use { |
238
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
239
|
0
|
|
|
|
|
|
my ( $name, $opt ) = @_; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
#now cut block_name |
242
|
0
|
|
|
|
|
|
my ( $b1, @bn ) = @{ $self->_opt2array($opt) }; |
|
0
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
my $key = $b1->{name}; |
244
|
0
|
|
|
|
|
|
my $block_opt = join " " => map { $_->{pod} } @bn; |
|
0
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
$self->use->{$key} = $name; |
246
|
0
|
|
|
|
|
|
$self->{_use_init}->{$name} = $block_opt; |
247
|
0
|
|
|
|
|
|
return { $key => $block_opt }; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 encoding |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
return ref to hash of pod options per blockname |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub encoding { |
257
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_encoding}; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
1; |
262
|
|
|
|
|
|
|
__END__ |